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