---
title: Tennis
description: Tennis Kata
---

[Katas ](https://www.codurance.com/katas)

# [Tennis](https://www.codurance.com/katas/tennis)

 Written by [Coding Dojo](https://www.codurance.com/katas/author/coding-dojo) | Aug 25, 2022 11:25:25 AM

### Summary

This kata is well suited to developers who have some familiarity with TDD basics and want to improve their algorithm design skills. It is a stateless, algorithmic version of the classic Tennis kata (where the program also holds the current score and updates its state when a player scores a new point).

Both Tennis and [Bowling](https://katalyst.codurance.com/bowling) can also be done holding state (e.g. with a `scorePoint()` method of some sort). However, when learning pure algorithmic TDD, we prefer to stay stateless as the added difficulty of maintaining state can distract from the main learning points.

### Instructions

Write a program that accepts two integers, and converts them to a tennis-style score.

The scoring rules of tennis (per [Wikipedia](https://en.wikipedia.org/wiki/Tennis#Scoring)) are as follows:

- A game is won by the first player to have won at least four points in total and at least two points more than the opponent.
- Scores from zero to three points are described as “love”, “fifteen”, “thirty”, and “forty” respectively.
- If at least three points have been scored by each player and the scores are equal, the score is “deuce”.
- If at least three points have been scored by each player and a player has one more point than his opponent, the score is “advantage” for the player in the lead.

Start with with the following interface:

```
public class TennisScoreCalculator {    public string Score(int player1Points, int player2Points);}
```

[View full post](https://www.codurance.com/katas/tennis)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Coding Dojo"
  },
  "dateModified" : "2022-09-05T13:18:51.344Z",
  "datePublished" : "2022-08-25T11:25:25Z",
  "headline" : "Tennis",
  "image" : {
    "@type" : "ImageObject",
    "height" : 630,
    "url" : "https://3042464.fs1.hubspotusercontent-na1.net/hubfs/3042464/Katalyst/Thumbnails/Katalyst_Thumbnail_Tennis.jpg",
    "width" : 1200
  },
  "mainEntityOfPage" : "https://www.codurance.com/katas/tennis",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Katas"
  }
}
```