@@ -156,12 +156,12 @@ methodはstructの上でしか使用されないのでしょうか?当然違
156
156
b.color = c
157
157
}
158
158
159
- func (bl BoxList) BiggestColor () Color {
159
+ func (bl BoxList) BiggestsColor () Color {
160
160
v := 0.00
161
161
k := Color(WHITE)
162
162
for _, b := range bl {
163
- if bv := b.Volume(); bv > v {
164
- v = bv
163
+ if b.Volume() > v {
164
+ v = b.Volume()
165
165
k = b.color
166
166
}
167
167
}
@@ -192,13 +192,13 @@ methodはstructの上でしか使用されないのでしょうか?当然違
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.BiggestColor ().String())
195
+ fmt.Println("The biggest one is", boxes.BiggestsColor ().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.BiggestColor ().String())
201
+ fmt.Println("Obviously, now, the biggest one is", boxes.BiggestsColor ().String())
202
202
}
203
203
204
204
上のコードはconstでいくつかの定数を定義しています。その後カスタム定義型を定義しています。
@@ -211,7 +211,7 @@ methodはstructの上でしか使用されないのでしょうか?当然違
211
211
212
212
- Volume()はレシーバをBoxとして定義します。Boxの体積を返します。
213
213
- SetColor(c Color)はBoxの色をcに変更します。
214
- - BiggestColor ()はBoxListに定義されており、listの中の体積が最大の色を返します。
214
+ - BiggestsColor ()はBoxListに定義されており、listの中の体積が最大の色を返します。
215
215
- PaintItBlack()はBoxListのすべてのBoxの色を全部黒に変更します。
216
216
- String()はColorに定義されており、Colorの具体的な色を返します(文字列形式)
217
217
0 commit comments