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
Binary file modified bin/TennisGame.class
Binary file not shown.
Binary file modified bin/TennisGameTest.class
Binary file not shown.
4 changes: 2 additions & 2 deletions src/TennisGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String getScore() {
return "player2 wins";
}

if (player1Points >= 4 && player1Points == player2Points)
if (player1Points >= 3 && player1Points == player2Points)
return "deuce";

if (player1Points >= 4 && player1Points - player2Points == 1)
Expand All @@ -86,6 +86,6 @@ public String getScore() {
if (player2Points > 4 && player2Points - player1Points == 1)
return "player2 has advantage";

return player2Score + " - " + player1Score ;
return player1Score + " - " + player2Score ;
}
}
55 changes: 55 additions & 0 deletions tests/TennisGameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,61 @@ public class TennisGameTest {
// "player2 has advantage"
// "player1 wins"
// "player2 wins"

@Test
public void testScore() throws TennisGameException {


TennisGame game = new TennisGame() ;
game.player1Scored();

assertEquals("15 - love" ,game.getScore());
}

@Test
public void testPlayer1Advantage() throws TennisGameException {


TennisGame game = new TennisGame() ;
game.player1Scored();
game.player1Scored();
game.player1Scored();
game.player2Scored();
game.player2Scored();
game.player2Scored();
game.player1Scored();
assertEquals("player1 has advantage" ,game.getScore());
}

@Test
public void testPlayer2Wins() throws TennisGameException {


TennisGame game = new TennisGame() ;
game.player2Scored();
game.player2Scored();
game.player2Scored();
game.player2Scored();

assertEquals("player2 wins" ,game.getScore());
}


@Test
public void testDeuce() throws TennisGameException {


TennisGame game = new TennisGame() ;
game.player2Scored();
game.player2Scored();
game.player2Scored();
game.player1Scored();
game.player1Scored();
game.player1Scored();

assertEquals("deuce" ,game.getScore());
}

@Ignore
public void testTennisGame_Start() {
//Arrange
Expand Down