/
double_flower_type.go
68 lines (58 loc) · 1.18 KB
/
double_flower_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package block
// DoubleFlowerType represents a type of double flower.
type DoubleFlowerType struct {
doubleFlower
}
type doubleFlower uint8
// Sunflower is a sunflower plant.
func Sunflower() DoubleFlowerType {
return DoubleFlowerType{0}
}
// Lilac is a lilac plant.
func Lilac() DoubleFlowerType {
return DoubleFlowerType{1}
}
// RoseBush is a rose bush plant.
func RoseBush() DoubleFlowerType {
return DoubleFlowerType{4}
}
// Peony is a peony plant.
func Peony() DoubleFlowerType {
return DoubleFlowerType{5}
}
// Uint8 returns the double plant as a uint8.
func (d doubleFlower) Uint8() uint8 {
return uint8(d)
}
// Name ...
func (d doubleFlower) Name() string {
switch d {
case 0:
return "Sunflower"
case 1:
return "Lilac"
case 4:
return "Rose Bush"
case 5:
return "Peony"
}
panic("unknown double plant type")
}
// String ...
func (d doubleFlower) String() string {
switch d {
case 0:
return "sunflower"
case 1:
return "syringa"
case 4:
return "rose"
case 5:
return "paeonia"
}
panic("unknown double plant type")
}
// DoubleFlowerTypes ...
func DoubleFlowerTypes() []DoubleFlowerType {
return []DoubleFlowerType{Sunflower(), Lilac(), RoseBush(), Peony()}
}