Question: Design a program in java that will allow a user to keep track of the status of a soccer game. You will design a SoccerGame
Design a program in java that will allow a user to keep track of the status of a soccer game. You will design a SoccerGame class that will represent the state of the soccer game.
Its attributes are:
The name of the first team
The name of the second team
The score of the first team
The score of the second team
The status of the game (finished or in progress)
The constructor will pass in two team names and will create a SoccerGame object where the score of each team is 0 and the status of the game is in progress.
The methods for the SoccerGame class are:
Record a goal scored (add one to the team score)
Change status of the game as finished
Return the score of a team
Return the name of the team that is currently winning or has won the game
You will design a test class that allows the user to instantiate a SoccerGame object for a current game.
The user will enter the names of two teams and the program will start a soccerGame object. Then the program will allow the user to update the object as needed until the game ends.
The program will loop and allow the score to be updated each time a team scores a goal until the game has finished. At that time, the user will get the score of each team and then get the name of the team that has won the game.
The program will also change the status of the game to finished.
Test Cases:
Provide two test cases, presenting the inputs and required outputs for each case, and the resulting action of the program.
Program Files:
SoccerGame.java, TestSoccerGame.java, and TestSoccerGame.png.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
