diff --git a/.besouro/20160927160032766/actions.txt b/.besouro/20160927160032766/actions.txt new file mode 100644 index 0000000..3ef5f81 --- /dev/null +++ b/.besouro/20160927160032766/actions.txt @@ -0,0 +1,22 @@ +FileOpenedAction 1474981233035 TennisGameException.java 57 0 0 0 +UnitTestCaseAction 1474981237506 TennisGameTest.java OK +UnitTestSessionAction 1474981237506 TennisGameTest.java OK +RefactoringAction 1474981383310 TennisGameTest.java ADD void testTennisGame_Player1WinsPointAfterGameEnded_ResultsException()/2 METHOD +RefactoringAction 1474981395981 TennisGameTest.java RENAME testTennisGame_Player1WinsPointAfterGameEnded_ResultsException()/2=>void testTennisGame_Player1Wins() METHOD +EditAction 1474981588350 TennisGameTest.java 1893 4 27 3 +UnitTestCaseAction 1474981589134 TennisGameTest.java OK +UnitTestSessionAction 1474981589150 TennisGameTest.java OK +EditAction 1474981606025 TennisGameTest.java 1895 4 26 3 +UnitTestCaseAction 1474981606441 TennisGameTest.java OK +UnitTestSessionAction 1474981606441 TennisGameTest.java OK +EditAction 1474981616794 TennisGameTest.java 1897 4 25 3 +UnitTestCaseAction 1474981617249 TennisGameTest.java OK +UnitTestSessionAction 1474981617249 TennisGameTest.java OK +EditAction 1474981631858 TennisGameTest.java 1893 4 27 3 +UnitTestCaseAction 1474981634260 TennisGameTest.java OK +UnitTestSessionAction 1474981634260 TennisGameTest.java OK +EditAction 1474981754276 TennisGameTest.java 1842 4 27 3 +EditAction 1474981776441 TennisGameTest.java 1842 4 27 3 +UnitTestCaseAction 1474981778436 TennisGameTest.java OK +UnitTestSessionAction 1474981778437 TennisGameTest.java OK +EditAction 1474982016716 TennisGameTest.java 1839 4 27 3 diff --git a/.besouro/20160927160032766/besouroEpisodes.txt b/.besouro/20160927160032766/besouroEpisodes.txt new file mode 100644 index 0000000..9deb8f9 --- /dev/null +++ b/.besouro/20160927160032766/besouroEpisodes.txt @@ -0,0 +1,6 @@ +1474981237506 regression 1 4 true +1474981589150 test-addition 1 205 true +1474981606441 refactoring 1A 0 true +1474981617249 refactoring 1A 0 true +1474981634260 refactoring 1A 2 true +1474981778437 regression 1 24 true diff --git a/.besouro/20160927160032766/disagreements.txt b/.besouro/20160927160032766/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20160927160032766/randomHeuristicEpisodes.txt b/.besouro/20160927160032766/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..c260be8 --- /dev/null +++ b/.besouro/20160927160032766/randomHeuristicEpisodes.txt @@ -0,0 +1,6 @@ +1474981237506 regression 1 4 false +1474981589150 test-addition 1 205 true +1474981606441 refactoring 1A 0 false +1474981617249 refactoring 1A 0 true +1474981634260 refactoring 1A 2 true +1474981778437 regression 1 24 true diff --git a/.besouro/20160927160032766/userComments.txt b/.besouro/20160927160032766/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20160927160032766/zorroEpisodes.txt b/.besouro/20160927160032766/zorroEpisodes.txt new file mode 100644 index 0000000..1e913d3 --- /dev/null +++ b/.besouro/20160927160032766/zorroEpisodes.txt @@ -0,0 +1,6 @@ +1474981237506 regression 1 4 false +1474981589150 test-addition 1 351 false +1474981606441 refactoring 1A 17 false +1474981617249 refactoring 1A 10 false +1474981634260 refactoring 1A 17 false +1474981778437 regression 1 144 false diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..b02130c --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,3 @@ +/TennisGame.class +/TennisGameException.class +/TennisGameTest.class diff --git a/bin/TennisGame.class b/bin/TennisGame.class index 2da4e7a..664ef75 100644 Binary files a/bin/TennisGame.class and b/bin/TennisGame.class differ diff --git a/bin/TennisGameTest.class b/bin/TennisGameTest.class index 4644c0b..7bf2430 100644 Binary files a/bin/TennisGameTest.class and b/bin/TennisGameTest.class differ diff --git a/src/TennisGame.java b/src/TennisGame.java index 327f284..fda5041 100644 --- a/src/TennisGame.java +++ b/src/TennisGame.java @@ -23,7 +23,7 @@ else if (player2Points>=4 && player2Points-player1Points>=2) private String getScore(int points) { switch (points) { - case 0: return "love"; + case 0: return "0"; case 1: return "15" ; case 2: return "30" ; case 3: return "40"; @@ -52,14 +52,15 @@ public void player2Scored() throws TennisGameException { } public String getScore() { + // Here is the format of the scores: -// "love - love" +// "0 - 0" // "15 - 15" // "30 - 30" // "deuce" -// "15 - love", "love - 15" -// "30 - love", "love - 30" -// "40 - love", "love - 40" +// "15 - 0", "0 - 15" +// "30 - 0", "0 - 30" +// "40 - 0", "0 - 40" // "30 - 15", "15 - 30" // "40 - 15", "15 - 40" // "player1 has advantage" diff --git a/tests/TennisGameTest.java b/tests/TennisGameTest.java index 98e6414..144d6b0 100644 --- a/tests/TennisGameTest.java +++ b/tests/TennisGameTest.java @@ -25,7 +25,7 @@ public void testTennisGame_Start() { //Act String score = game.getScore() ; // Assert - assertEquals("Initial score incorrect", "love - love", score); + assertEquals("Initial score incorrect", "0 - 0", score); } @Test @@ -50,6 +50,8 @@ public void testTennisGame_EahcPlayerWin4Points_Score_Deuce() throws TennisGameE } @Test (expected = TennisGameException.class) + + public void testTennisGame_Player1WinsPointAfterGameEnded_ResultsException() throws TennisGameException { //Arrange TennisGame game = new TennisGame(); @@ -61,5 +63,18 @@ public void testTennisGame_Player1WinsPointAfterGameEnded_ResultsException() thr //Act // This statement should cause an exception game.player1Scored(); - } + } + + public void testTennisGame_Player1Wins() throws TennisGameException { + //Arrange + TennisGame game = new TennisGame(); + //Act + game.player1Scored(); + game.player1Scored(); + game.player1Scored(); + game.player1Scored(); + String score = game.getScore(); + assertEquals("The winner is", "player2 wins", score); + + } }