1
+ Bowling is game where players roll a heavy ball to knock down pins
2
+ arranged in a triangle. Write code to keep track of the score
3
+ of a game of bowling.
4
+
1
5
## Scoring Bowling
2
6
3
7
The game consists of 10 frames. In each frame the player has two
@@ -6,20 +10,22 @@ total number of pins knocked down, plus bonuses for strikes and spares.
6
10
7
11
A spare is when the player knocks down all 10 pins in two tries. The
8
12
bonus for that frame is the number of pins knocked down by the next
9
- roll. So in frame 3 above, the score is 10 (the total number knocked
10
- down) plus a bonus of 5 (the number of pins knocked down on the next
11
- roll.)
13
+ roll. For example a player rolls in the first three frames respectively
14
+ 4+2, 3+7 and 5+1. For frame 2, the score is 10 ( the total number knocked
15
+ down) plus a bonus of 5 (the number of pins knocked down on the next roll.)
12
16
13
17
A strike is when the player knocks down all 10 pins on his first try.
14
- The bonus for that frame is the value of the next two balls rolled.
18
+ The bonus for that frame is the value of the next two balls rolled
19
+ (the value of the next frame, not counting the bonus).
15
20
16
21
In the tenth frame a player who rolls a spare or strike is allowed to
17
22
roll the extra balls to complete the frame. However no more than three
18
23
balls can be rolled in tenth frame.
19
24
20
25
## Requirements
21
26
22
- Write a class named “Game” that has two methods:
27
+ Write code to keep track of the score of a game of bowling. It should
28
+ support two operations:
23
29
24
30
* ` roll(pins : int) ` is called each time the player rolls a ball. The
25
31
argument is the number of pins knocked down.
0 commit comments