-
Notifications
You must be signed in to change notification settings - Fork 0
S5_Scoreboard_Hard
Your task is to design a software scoreboard system that can handle a wide variety of sports.
Construct a class hierarchy that allows you to score football, basketball, soccer, and hockey.
You must at a minimum include methods that:
set the teams
get the teams
get the scores for each team
addScore
getScoringMethods
start the game
end the current period of play
get the current period of play
get length of period
get name of period (quarter, half, etc.)
is the game over?
winning team
Example demo application:
Team dirt = new Team("Cyclones");
Game hyveeCyHawk = new Football(dirt, hawk);
ScoringMethod touchdown = hyveeCyHawk.getScoringMethods().get(0);
hyveeCyHawk.addScore(touchdown, hawk);
Construct a command line interface that allows a user to select the type of game from the hierarchy above, and interactively keep score of the game. Your interface should be written in a generic way using polymorphism. No credit will be granted for a user interface with game‐specific code. For example your Football class should not contain a method that prints out a portion of the user interface. Outputs to the screen and user input must ONLY exist in the main method or you will lose points.
Example:
Select the type of game:
1. Football
2. Baseball
3. Soccer
4. Hockey
Enter Choice: 1
Enter Home Team: Cyclones
Enter Away Team: Hawkeyes
Cyclones – 0, Hawkeyes – 0
Current quarter: 1
Menu:
1. Cyclones touchdown
2. Cyclones field goal
3. Cyclones extra-point
4. Cyclones two-point conversion
5. Cyclones safety
6. Hawkeyes touchdown
7. Hawkeyes field goal
8. Hawkeyes extra-point
9. Hawkeyes two-point conversion
10. Hawkeyes safety
11. End quarter
Enter choice: 6
Cyclones – 0, Hawkeyes – 6
Current quarter: 1
Menu:
1. Cyclones touchdown
2. Cyclones field goal
3. Cyclones extra-point
4. Cyclones two-point conversion
5. Cyclones safety
6. Hawkeyes touchdown
7. Hawkeyes field goal
8. Hawkeyes extra-point
9. Hawkeyes two-point conversion
10. Hawkeyes safety
11. End quarter
Enter choice: 8
GAME CONTINUES UNTIL...
Cyclones – 2, Hawkeyes – 70
Current quarter: 4
Menu:
1. Cyclones touchdown
2. Cyclones field goal
3. Cyclones extra-point
4. Cyclones two-point conversion
5. Cyclones safety
6. Hawkeyes touchdown
7. Hawkeyes field goal
8. Hawkeyes extra-point
9. Hawkeyes two-point conversion
10. Hawkeyes safety
11. End quarter
Enter choice: 11
Game is over.
Cyclones – 2, Hawkeyes – 70
Current quarter: Final
Winner: Hawkeyes
When the program starts you will be asked to choose what game to simulate. Once you have chosen you will then choose a name for both teams. After a game with the given information will be created and you will be asked to input choices for the game. Choices include scoring for either team or ending the current period. Once the game has ended the results will be printed to the screen and the program will end. To simulate another game simply run the program again.
There are 4 hard coded games: Basketball
, Football
, Hockey
, and Soccer
. Each extend the Game
class and have a single constructor that gives all the required information to the Game
constructor and then creates and add scoring methods for that specific game. Game
consists of 2 teams, which can initially null, a period which cannot and scoring methods which can be initially empty. Game
has a bunch of public methods to edit and change the game state. Once a Game
reaches a current period exceeding the total number of periods the game is considered over. GameSimulator
runs a simluation for a game once the GameSimulator#startSimulation()
method is called. It handles user input and output. Asks to select the type of game and the two teams. Then it asks to choose options from a list that effect the game state. If invalid input is given then nothing is simulated and input is asked for again. The simulation runs until the end of the simulated game is reached. which ends the call to GameSimulator#startSimulation()
and exits the program.
UML Diagram:
The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.
cd ~/git
python -m SimpleHTTPServer&
Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:
python3 -m http.server