Kaynağa Gözat

Changed some parameters and statements

TimoleonLatinopoulos 8 yıl önce
ebeveyn
işleme
d5ba632235

+ 5
- 5
exercises/bowling/.meta/src/reference/java/BowlingGame.java Dosyayı Görüntüle

@@ -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
-                if (strikeBonus > MAXIMUM_FRAME_SCORE && !isStrike(frameIndex + 1) && spareBonus(frameIndex) > 10) {
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
+}

+ 1
- 1
exercises/bowling/src/test/java/BowlingTest.java Dosyayı Görüntüle

@@ -190,7 +190,7 @@ public class BowlingTest {
190 190
     @Ignore("Remove to run test")
191 191
     @Test
192 192
     public void bonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
193
-        int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11};
193
+        int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 0};
194 194
 
195 195
         playGame(rolls);
196 196