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
contract deck {
enum suit {
club,
diamonds,
hearts,
spades
}
enum value {
two,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
jack,
queen,
king,
ace
}
struct card {
value v;
suit s;
}
function score(card c) public returns (uint32 score) {
if (c.s == suit.hearts) {
if (c.v == value.ace) {
score = 14;
}
if (c.v == value.king) {
score = 13;
}
if (c.v == value.queen) {
score = 12;
}
if (c.v == value.jack) {
score = 11;
}
}
// all others score 0
}
}