@Test public void testOneSpare() throws Exception { rollSpare(); g.roll(3); rollMany(17, 0); assertEquals(16, g.score()); }
@Test public void testOneStrike() throws Exception { rollStrike(); g.roll(3); g.roll(4); rollMany(16, 0); assertEquals(24, g.score()); }
public void testAlternatiing() throws Exception { for (int i = 0; i < 5; i++) { game.roll(10); game.roll(4); game.roll(6); } game.roll(10); assertEquals(200, game.score()); }
public void testThreesWithFrameCounting() throws Exception { assertEquals(0, game.finishedFrames()); for (int frame = 1; frame <= 10; frame++) { game.roll(3); game.roll(3); assertEquals(frame, game.finishedFrames()); assertEquals(frame, game.scoredFrames()); } assertEquals(60, game.score()); }
public void testPerfectWithPinsStanding() throws Exception { for (int frame = 1; frame <= 9; frame++) { assertEquals(10, game.pinsStanding()); game.roll(10); } assertEquals(10, game.pinsStanding()); game.roll(10); assertEquals(10, game.pinsStanding()); game.roll(10); assertEquals(10, game.pinsStanding()); game.roll(10); assertEquals(300, game.score()); }
public void play(Outcome result, Tie tie) { int s1 = p1.play(); int s2 = p2.play(); double player1score = game.score(s1, s2); double player2score = game.score(s2, s1); if (player1score == player2score) { tie.tie(s1, s2, player1score); } else if (player1score > player2score) { result.outcome(p1, s1, player1score, p2, s2, player2score); } else if (player2score > player1score) { result.outcome(p2, s2, player2score, p1, s1, player1score); } }
public void testSpareWithFrameCounting() throws Exception { assertEquals(0, game.scoredFrames()); game.roll(4); assertEquals("4", arrayAsString(game.rollsForFrame(1))); game.roll(6); assertEquals(1, game.finishedFrames()); assertEquals(0, game.scoredFrames()); // cant score it yet assertEquals("4 6", arrayAsString(game.rollsForFrame(1))); game.roll(5); assertEquals(1, game.scoredFrames()); // can score it now game.roll(3); assertEquals(2, game.finishedFrames()); assertEquals(2, game.scoredFrames()); // score right away rollMany(16, 0); assertEquals(10, game.finishedFrames()); assertTrue(game.gameOver()); assertEquals(10, game.scoredFrames()); assertEquals(23, game.score()); }
public void testPerfectWithFrameCounting() throws Exception { for (int frame = 1; frame <= 9; frame++) { game.roll(10); assertEquals(frame, game.finishedFrames()); } assertEquals(7, game.scoredFrames()); game.roll(10); assertEquals(9, game.finishedFrames()); // done with 9 assertEquals(8, game.scoredFrames()); assertEquals("10", arrayAsString(game.rollsForFrame(10))); game.roll(10); // still done with 9 assertEquals(9, game.finishedFrames()); assertEquals(9, game.scoredFrames()); assertEquals("10 10", arrayAsString(game.rollsForFrame(10))); game.roll(10); // finally, done with 9 assertEquals(10, game.finishedFrames()); assertEquals(10, game.scoredFrames()); assertEquals(300, game.score()); assertEquals("10 10 10", arrayAsString(game.rollsForFrame(10))); }
public void testSpareAtEndWithFrameCounting() throws Exception { rollMany(18, 4); assertEquals(9, game.finishedFrames()); assertEquals(9, game.scoredFrames()); assertEquals(72, game.scoreForFrame(9)); game.roll(7); assertEquals(9, game.finishedFrames()); assertEquals(9, game.scoredFrames()); assertEquals(3, game.pinsStanding()); game.roll(3); // complete the spare assertEquals(9, game.finishedFrames()); assertEquals(9, game.scoredFrames()); assertEquals(10, game.pinsStanding()); game.roll(6); // get an extra 6 pins, finishing the frame and game assertEquals(10, game.finishedFrames()); assertEquals(10, game.scoredFrames()); assertEquals(72 + 10 + 6, game.score()); }
public void testStrikeWithFrameCounting() throws Exception { game.roll(10); assertEquals(1, game.finishedFrames()); assertEquals(0, game.scoredFrames()); assertEquals(10, game.pinsStanding()); game.roll(5); assertEquals(1, game.finishedFrames()); assertEquals(0, game.scoredFrames()); game.roll(3); assertEquals(2, game.finishedFrames()); assertEquals(2, game.scoredFrames()); // that roll scored frames 1 and 2 game.roll(2); assertEquals(2, game.finishedFrames()); game.roll(1); assertEquals(3, game.finishedFrames()); assertEquals(3, game.scoredFrames()); rollMany(14, 0); assertEquals(10, game.finishedFrames()); assertEquals(10, game.scoredFrames()); assertEquals(29, game.score()); assertEquals("10", arrayAsString(game.rollsForFrame(1))); assertEquals("5 3", arrayAsString(game.rollsForFrame(2))); }
public void testPerfect() throws Exception { rollMany(12, 10); assertEquals(300, game.score()); }
public void testThrees() throws Exception { rollMany(20, 3); assertEquals(60, game.score()); }
public void testGutterBalls() throws Exception { rollMany(20, 0); assertEquals(0, game.score()); }
@Test public void testAllOnes() throws Exception { rollMany(20, 1); assertEquals(20, g.score()); }
@Test public void testGutterGame() throws Exception { rollMany(20, 0); assertEquals(0, g.score()); }