Tennis
About this Kata
This Kata is about implementing a simple tennis game. I came up with it while thinking about Wii tennis, where they have simplified tennis, so each set is one game.
The scoring system is rather simple:
-
Each player can have either of these points in one game 0 15 30 40
-
If you have 40 and you win the ball you win the game, however there are special rules.
-
If both have 40 the players are deuce.
-
If the game is in deuce, the winner of a ball will have advantage and game ball.
-
If the player with advantage wins the ball he wins the game.
-
If the player without advantage wins they are back at deuce.
-
Alternate description of the rules per Wikipedia: http://en.wikipedia.org/wiki/Tennis#Scoring
Note
|
The examples shown here are generated from the source code. They therefore represent the behavior of the application at any times. Non regression is ensured by checking the absence of change in this document. Learn more here https://github.com/sfauvel/documentationtesting |
View source of project on Github
Scores examples
We will display a tennis score.
Start of the game
At the beginning, score is 0 / 0.
Player A |
0 - 0 |
Player B |
Player A win one point
When player A win one point, score is 15 / 0.
Player A |
✔ |
15 - 0 |
Player B |
Player B win one point
When player B win one point, score is 0 / 15.
Player A |
0 - 15 |
|
Player B |
✔ |
Player A win two points
When player A win two points, score is 30 / 0.
Player A |
✔ |
✔ |
30 - 0 |
Player B |
Player B win two points
When player B win two points, score is 0 / 30.
Player A |
0 - 30 |
||
Player B |
✔ |
✔ |
Both players win some points
When player A win 2 points and player B win 3 points, score is 30 / 40.
Player A |
✔ |
✔ |
30 - 40 |
|||
Player B |
✔ |
✔ |
✔ |