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