...
1 package joker
2
3
4 type CardSuit int
5
6
7 const (
8 SuitHearts CardSuit = 1
9 SuitDiamonds CardSuit = 2
10 SuitClubs CardSuit = 3
11 SuitSpades CardSuit = 4
12 SuitJoker CardSuit = 5
13 )
14
15
16 var StandardSuits = []CardSuit{
17 SuitHearts,
18 SuitDiamonds,
19 SuitClubs,
20 SuitSpades,
21 }
22
23
24 var AllSuits = []CardSuit{
25 SuitHearts,
26 SuitDiamonds,
27 SuitClubs,
28 SuitSpades,
29 SuitJoker,
30 }
31
32
33 const (
34 SymbolHearts = "♥"
35 SymbolDiamonds = "♦"
36 SymbolClubs = "♣"
37 SymbolSpades = "♠"
38 SymbolJoker = "!"
39 )
40
41
42 func (s CardSuit) Symbol() string {
43 switch s {
44 case SuitHearts:
45 return SymbolHearts
46 case SuitDiamonds:
47 return SymbolDiamonds
48 case SuitClubs:
49 return SymbolClubs
50 case SuitSpades:
51 return SymbolSpades
52 case SuitJoker:
53 return SymbolJoker
54 default:
55 return Invalid
56 }
57 }
58
59
60 func (s CardSuit) Name() string {
61 switch s {
62 case SuitHearts:
63 return "Hearts"
64 case SuitDiamonds:
65 return "Diamonds"
66 case SuitClubs:
67 return "Clubs"
68 case SuitSpades:
69 return "Spades"
70 case SuitJoker:
71 return "Joker"
72 default:
73 return Invalid
74 }
75 }
76
77
78 func (s CardSuit) String() string {
79 return s.Name()
80 }
81
View as plain text