Merge commit '395dc46f88cdc324dc329a3d3bb51082b03f1dae' into ja

This commit is contained in:
Shin Kojima
2014-09-21 21:30:31 +09:00

View File

@@ -156,7 +156,7 @@ method的语法如下
b.color = c
}
func (bl BoxList) BiggestsColor() Color {
func (bl BoxList) BiggestColor() Color {
v := 0.00
k := Color(WHITE)
for _, b := range bl {
@@ -192,13 +192,13 @@ method的语法如下
fmt.Printf("We have %d boxes in our set\n", len(boxes))
fmt.Println("The volume of the first one is", boxes[0].Volume(), "cm³")
fmt.Println("The color of the last one is",boxes[len(boxes)-1].color.String())
fmt.Println("The biggest one is", boxes.BiggestsColor().String())
fmt.Println("The biggest one is", boxes.BiggestColor().String())
fmt.Println("Let's paint them all black")
boxes.PaintItBlack()
fmt.Println("The color of the second one is", boxes[1].color.String())
fmt.Println("Obviously, now, the biggest one is", boxes.BiggestsColor().String())
fmt.Println("Obviously, now, the biggest one is", boxes.BiggestColor().String())
}
上面的代码通过const定义了一些常量然后定义了一些自定义类型
@@ -211,7 +211,7 @@ method的语法如下
- Volume()定义了接收者为Box返回Box的容量
- SetColor(c Color)把Box的颜色改为c
- BiggestsColor()定在在BoxList上面返回list里面容量最大的颜色
- BiggestColor()定在在BoxList上面返回list里面容量最大的颜色
- PaintItBlack()把BoxList里面所有Box的颜色全部变成黑色
- String()定义在Color上面返回Color的具体颜色(字符串格式)