Lab 5 - Tennis
You may have a partner for this lab; but make sure both of you understand what you are doing!
Introduction:
Your task is to write a Java application that will keep track of the
score in a tennis match. It should announce the score before each point, as well as the
winner of each game, set, and finally the match. The winner of a tennis match is, like in
Wimbledon Women's Tennis, the first player to win two sets. A player wins a set if they
have won at least 6 games and are at least 2 games ahead (we will not handle tie-
breakers).
The same player serves for an entire tennis game. Before each point, the score is
announced, server's score first. In tennis, scores of
zero, one, two, three, and four, are announced as love, fifteen, thirty and forty. Thus,
if the server has two points, and the receiver, one, the score should be announced as: thirty-fifteen.
A game is won when one of the players has at least five
points and is at least two points ahead. If the score reaches 4-4, then, until the game is
decided, the score is announced as "deuce" for ties and "advantage server" or "advantage
receiver", depending on who is ahead by one.
Assume for now that the user will push one of two Buttons for each point, one if the
server gets the point, the other if the receiver gets the point.
How to proceed:
- Understand the problem
- What will the user do?
- What will your program do when the user pushes a button?
- How will your program do that? What objects will say what to what other objects?
- Where will the two scores be?
- Decide what classes to write, where information will be stored.
Here's one set:
- TennisFrame: The Frame that the user will interact with
- Set: keeps track of the status of the set
- Game: keeps track of the score in a single game
- Converter: converts ints 0, 1, 2, 3 to "love", "fifteen", "thirty", "forty"
- Draw pictures
- The Frame that the user will interact with
- The classes you will use
- Build a prototype!
- Keep score for one game
- Keep score for one set
Parital credit:
You may earn most of the credit for keeping score for one set (instead of the whole match).
Extra credit:
Add pictures of two players!
How to get credit: demo with your partner in lab on Thurs; don't forget lab is available from 4-10!