Преглед на файлове

Merge pull request #1222 from TimoleonLatinopoulos/master

Added test cases as per #1161
Sam Warner преди 8 години
родител
ревизия
ad7e33eb59
No account linked to committer's email

+ 1
- 1
exercises/bowling/.meta/src/reference/java/BowlingGame.java Целия файл

@@ -25,7 +25,7 @@ class BowlingGame {
25 25
                 }
26 26
 
27 27
                 int strikeBonus = strikeBonus(frameIndex);
28
-                if (strikeBonus > MAXIMUM_FRAME_SCORE && !isStrike(frameIndex + 1)) {
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 30
                 }
31 31
 

+ 1
- 0
exercises/bowling/.meta/version Целия файл

@@ -0,0 +1 @@
1
+1.1.0

+ 40
- 1
exercises/bowling/src/test/java/BowlingTest.java Целия файл

@@ -189,6 +189,19 @@ public class BowlingTest {
189 189
 
190 190
     @Ignore("Remove to run test")
191 191
     @Test
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, 10, 11, 0};
194
+
195
+        playGame(rolls);
196
+
197
+        expectedException.expect(IllegalStateException.class);
198
+        expectedException.expectMessage("Pin count exceeds pins on the lane");
199
+
200
+        game.score();
201
+    }
202
+    
203
+    @Ignore("Remove to run test")
204
+    @Test
192 205
     public void twoBonusRollsAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
193 206
         int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 6};
194 207
 
@@ -209,7 +222,33 @@ public class BowlingTest {
209 222
 
210 223
         assertEquals(26, game.score());
211 224
     }
225
+    
226
+    @Ignore("Remove to run test")
227
+    @Test
228
+    public void theSecondBonusRollsAfterAStrikeInTheLastFrameCanNotBeAStrikeIfTheFirstOneIsNotAStrike() {
229
+        int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6, 10};
212 230
 
231
+        playGame(rolls);
232
+
233
+        expectedException.expect(IllegalStateException.class);
234
+        expectedException.expectMessage("Pin count exceeds pins on the lane");
235
+
236
+        game.score();
237
+    }
238
+    
239
+    @Ignore("Remove to run test")
240
+    @Test
241
+    public void secondBonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
242
+        int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 11};
243
+
244
+        playGame(rolls);
245
+
246
+        expectedException.expect(IllegalStateException.class);
247
+        expectedException.expectMessage("Pin count exceeds pins on the lane");
248
+
249
+        game.score();
250
+    }
251
+    
213 252
     @Ignore("Remove to run test")
214 253
     @Test
215 254
     public void anUnstartedGameCanNotBeScored() {
@@ -238,7 +277,7 @@ public class BowlingTest {
238 277
 
239 278
     @Ignore("Remove to run test")
240 279
     @Test
241
-    public void aGameWithMoreThanTenFramesCanNotBeScored() {
280
+    public void canNotRollIfGameAlreadyHasTenFrames() {
242 281
         int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
243 282
 
244 283
         playGame(rolls);