forked from exercism/problem-specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bowling.json
117 lines (117 loc) · 4.47 KB
/
bowling.json
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
"#": [
"Bowling is game where players roll a heavy ball to knock down pins",
"arranged in a triangle. Write code to keep track of the score of a",
"game of bowling."
],
"methods": {
"description": [
"Check the public API is correct."
],
"cases": [{
"description": "must be able to roll with a number of pins",
"method": "roll",
"arity": 1
}, {
"description": "must have a score",
"method": "score",
"arity": 0
}]
},
"score": {
"description": [
"Check game can be scored correctly."
],
"cases": [{
"description": "should be able to score open frame",
"rolls": [3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 7
}, {
"description": "should be able to score multiple frames",
"rolls": [3, 4, 2, 3, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 19
}, {
"description": "should be able to score a game with all gutterballs",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 0
}, {
"description": "should be able to score a game with all single pin rolls",
"rolls": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"expected": 20
}, {
"description": "should be able to score a game with all open frames",
"rolls": [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6],
"expected": 90
}, {
"description": "should be able to score a strike not in the last frame",
"rolls": [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 26
}, {
"description": "should be able to score a spare not in the last frame",
"rolls": [5, 5, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 20
}, {
"description": "should be able to score multiple strikes in a row",
"rolls": [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 81
}, {
"description": "should be able to score multiple spares in a row",
"rolls": [5, 5, 3, 7, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": 32
}, {
"description": "should allow fill balls when the last frame is a strike",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1],
"expected": 18
}, {
"description": "should allow fill ball when the last frame is a spare",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 1, 7],
"expected": 17
}, {
"description": "should allow fill balls to be a strike",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10],
"expected": 30
}, {
"description": "should be able to score a perfect game",
"rolls": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
"expected": 300
}]
},
"validations": {
"description": [
"Check game rules."
],
"cases": [{
"description": "should not allow rolls with negative pins",
"rolls": [-1],
"expected": "Pins must have a value from 0 to 10"
}, {
"description": "should not allow rolls better than strike",
"rolls": [11],
"expected": "Pins must have a value from 0 to 10"
}, {
"description": "should not allow two normal rolls better than strike",
"rolls": [5, 6],
"expected": "Pin count exceeds pins on the lane"
}, {
"description": "should not allow two normal rolls better than strike in last frame",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6],
"expected": "Pin count exceeds pins on the lane"
}, {
"description": "should not allow to take score at the beginning of the game",
"rolls": [],
"expected": "Score cannot be taken until the end of the game"
}, {
"description": "should not allow to take score before the game has ended",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": "Score cannot be taken until the end of the game"
}, {
"description": "should not allow rolls after the tenth frame",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"expected": "Should not be able to roll after game is over"
}, {
"description": "should not calculate score before fill balls have been played",
"rolls": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
"expected": "Score cannot be taken until the end of the game"
}]
}
}