This kata consists in implementing a Tennis match and below the rules :
💡 NB: A match is won when a player has won the majority of the prescribed number of sets (best-of-five) in this kata. A best-of-five is a head-to-head competition between two teams, wherein one must win three games to win the series. Three is chosen as it constituted a majority of games played. If one team wins the series before reaching game 5, all others are ignored.
- The game starts with a score of 0 point for each player
- Each time a player wins a point, the Game score changes as follow: 0 -> 15 -> 30 -> 40-> Win game.
- If the 2 players reach the score 40, the DEUCE rule is activated.
- If the score is DEUCE , the player who win the point take the ADVANTAGE.
- If the player who has the ADVANTAGE win the point, he wins the game.
- If the player who has the ADVANTAGE loses the point, the score is DEUCE.
- The set starts with a score of 0 Game for each player.
- Each time a player wins a Game (see SPRINT 1), the Set score changes as follow: 1 -> 2 -> 3 -> 4 -> 5 -> 6 (-> 7)
- If a player reaches the Set score of 6 and the other player has a Set score of 4 or lower, the player win the Set.
- If a player wins a Game and reach the Set score of 6 and the other player has a Set score of 5, a new Game must be played and the first player who reach the score of 7 wins the set.
- If the 2 players reach the score of 6 Games, the Tie-Break rule is activated.
- Each time a player wins a point, the score changes as follow 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 (-> 8-> 9-> 10-> …)
- The Tie-Break ends as soon as a player gets a least 7 points and 2 points more than his opponent.
- The player who wins the Tie-Break wins the Set.
The outcome of this implementation is a tennis score table as below :
Player Name Set 1 Set 2 Set 3 Set 4 Set 5
Serena Williams 6 6(8) 6(6) 5 0
Ones Jabeur 3 6(6) 6(8) 7 6
👉For more information see Tennis scoring system
- Souheil Naceur - Linkedin
To build you will need Git,JDK 11 and Maven 3.3.1 or newer. Be sure that your JAVA_HOME environment variable points to the jdk1.8.0 folder extracted from the JDK download.
git clone git@github.com:artjcod/TennisMatch.git
cd TennisMatch
To build Maven:
mvn install
- Jacoco plugin has been added to the pom configuration and it is part of the build report check the target/site/jacoco folder.
mvn clean test
mvn jacoco:report
- Findbugs plugin is used too and it fails the build in case of violation. To get the html report check the folder target/site once you have run the following command :
mvn clean test site
The application is using Log4j2 , a pre-configured log4j-configuration file is being used don't hesitate to customize.
This project is licensed under the MIT License - see the LICENSE.md file for details