Skip to content

TennisGame

Anthony Lawrence edited this page Mar 11, 2018 · 2 revisions

Programming Concepts (Kata: Tennis Game)

Definition of Kata

An individual training exercise (in Karate or other martial art)

Pre-requisite knowledge

  • A single game of tennis is as few as 4 "plays".
  • The "points", within a game, are scored as follows:
    • 0 points is "Love"
    • 1 point is "Fifteen"
    • 2 points is "Thirty"
    • 3 points is "Forty"
  • Players can only win where they have a clear, 2 point lead:
    • Where the scores are tied at or beyond 3 points ("Forty") the score is "Deuce"
    • Where one player is only winning by one point they are said to have an "Advantage"

Test Cases

Test Case 1

A new game should score "Love-All"

Test Case 2

Where player 1 has one point scores "Fifteen-Love"

Test Case 3

A game where player 1 has two points, scores "Thirty-Love"

Test Case 4

A game where player 1 has 3 points, scores "Forty-Love"

Test Case 5

A game where both players has 4 points, scores "Deuce"

Test Case 6

A game where player 1 has five points and player 2 has four points, scores "Advantage Player 1"

Test Case 7

A game where player 1 has six points, and player 2 has four points, scores "Win for Player 1"