|
|
@@ -23,12 +23,12 @@ class BowlingGame {
|
|
23
|
23
|
if (rolls.size() <= frameIndex + 2) {
|
|
24
|
24
|
throw new IllegalStateException("Score cannot be taken until the end of the game");
|
|
25
|
25
|
}
|
|
26
|
|
-
|
|
|
26
|
+
|
|
27
|
27
|
int strikeBonus = strikeBonus(frameIndex);
|
|
28
|
28
|
if (strikeBonus > MAXIMUM_FRAME_SCORE && !isStrike(frameIndex + 1) || spareBonus(frameIndex) > 10) {
|
|
29
|
29
|
throw new IllegalStateException("Pin count exceeds pins on the lane");
|
|
30
|
|
- }
|
|
31
|
|
-
|
|
|
30
|
+ }
|
|
|
31
|
+
|
|
32
|
32
|
score += 10 + strikeBonus;
|
|
33
|
33
|
frameIndex += i == NUMBER_OF_FRAMES ? 3 : 1;
|
|
34
|
34
|
} else if (isSpare(frameIndex)) {
|
|
|
@@ -81,4 +81,4 @@ class BowlingGame {
|
|
81
|
81
|
private int frameScore(int frameIndex) {
|
|
82
|
82
|
return rolls.get(frameIndex) + rolls.get(frameIndex + 1);
|
|
83
|
83
|
}
|
|
84
|
|
-}
|
|
|
84
|
+}
|