Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .besouro/20160927160032766/actions.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .besouro/20160927160032766/besouroEpisodes.txt
Original file line number Diff line number Diff line change
@@ -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
Empty file.
6 changes: 6 additions & 0 deletions .besouro/20160927160032766/randomHeuristicEpisodes.txt
Original file line number Diff line number Diff line change
@@ -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
Empty file.
6 changes: 6 additions & 0 deletions .besouro/20160927160032766/zorroEpisodes.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/TennisGame.class
/TennisGameException.class
/TennisGameTest.class
Binary file modified bin/TennisGame.class
Binary file not shown.
Binary file modified bin/TennisGameTest.class
Binary file not shown.
11 changes: 6 additions & 5 deletions src/TennisGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 17 additions & 2 deletions tests/TennisGameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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);

}
}