Skip to content

feedyou-ai/refactoring-kata-tennis-pavel-kocman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

refactoring-kata-tennis

Tennis Kata

Tennis has a rather quirky scoring system, and to newcomers it can be a little difficult to keep track of. The tennis society has contracted you to build a scoreboard to display the current score during tennis games.

Your task is to write a “TennisGame” class containing the logic which outputs the correct score as a string for display on the scoreboard. When a player scores a point, it triggers a method to be called on your class letting you know who scored the point. Later, you will get a call “score()” from the scoreboard asking what it should display. This method should return a string with the current score.

You can read more about Tennis scores here which is summarized below:

  1. A game is won by the first player to have scored at least four points in total and at least two points more than the opponent.
  2. The running score of each game is described in a manner peculiar to tennis: scores from zero to three points are described as "Love", "Fifteen", "Thirty", and "Forty" respectively.
  3. If at least three points have been scored by each player, and the scores are equal, the score is "Deuce".
  4. If at least three points have been scored by each side and a player has one more point than his opponent, the score of the game is "Advantage" for the player in the lead.

You need only report the score for the current game. Sets and Matches are out of scope.

What to do?

The functionality is in the file src/tennisScore.ts. The file index.ts is there so you can try to call the getScore() function if needed.

Check the package.json for prepared scripts, feel free to add/modify them.

  • create a fork and then keep your progress there
  • add tests to cover the functionality
  • refactor the code in src/tennisScore.ts

Commit your changes often so we can se see the progress.

Good luck :)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published