Parcourir la source

Changed some parameters and statements

TimoleonLatinopoulos il y a 8 ans
Parent
révision
d5ba632235

+ 5
- 5
exercises/bowling/.meta/src/reference/java/BowlingGame.java Voir le fichier

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

+ 1
- 1
exercises/bowling/src/test/java/BowlingTest.java Voir le fichier

190
     @Ignore("Remove to run test")
190
     @Ignore("Remove to run test")
191
     @Test
191
     @Test
192
     public void bonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
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
         playGame(rolls);
195
         playGame(rolls);
196
 
196