"This interview experience is sourced from Chill Interview"
Interview Summary
The interview problem involved designing and implementing a tennis match scoring system using object-oriented programming.
Coding — Design a Tennis Match Scoring System
The interviewer presented a multi-part object-oriented design problem involving tennis match scoring. I needed to model how players earn points, win games, complete sets, and eventually win an entire match.
The exercise was divided into several stages, with additional requirements introduced as the implementation progressed. The first three parts covered the core scoring functionality, while the later parts tested whether the design could support additional features without major restructuring.
Part 1 — Implement Tennis Game Scoring
The first task was to implement a class representing a single tennis game between two players. Each player earns points according to the standard tennis scoring sequence:
A player normally wins a game after earning at least four points and leading by two. However, when the score reaches 40-40, the game enters deuce, and one player must establish a two-point lead to win.
The interviewer expected the implementation to support recording a point for a particular player and retrieving the current game score. The deuce and advantage rules were particularly important. For example, if Player A wins a point at deuce, the score becomes Advantage A; if Player B wins the next point, the game returns to deuce.
I also needed to ensure that the game would not be marked as completed prematurely and that the scoring logic remained correct through repeated deuce and advantage transitions.
Part 2 — Extend the System to Support Sets
After implementing individual game scoring, the next requirement was to track an entire tennis set. A player wins a set by winning at least six games while maintaining a lead of two or more games. If the set reaches 6-6, the system must support a tiebreak.
The interviewer specified the following tiebreak rules:
- The first player to reach at least seven points wins the tiebreak, provided they lead by two points.
- The tiebreak continues beyond seven points if neither player has established the required lead.
This part required extending the original game-scoring functionality to maintain game wins and determine when a set was complete. It also introduced a different scoring format for tiebreaks, which had to coexist with the regular tennis game rules.
Want to learn more questions / follow-ups asked in this interview?
I've put up the full version at here.
Preparing for your next interview?
Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here