Write a Java program that implements the system shown in the following UML class diagram, which represents a football championship: Group Team teams: Team[] matches: boolean[][] name: String -players: Player] -points: int numOfTeams: int 4 +Group() + Team() + addTeam(team: Team) void + printTeamsPoints(): void + unplayed Matches(): int +qualified Teams():String + getNumOfTeams int + Team(name: String. players: Player[]) + getPlayers():Player[] +incrementPoints(amount: int):void +getPoints() int + setNumOfTeams(numOfTeams:int); void +playNextMatch(): Team Player +name: String + number: int - goals: int +Player() + Player(name: String, number int) +incrementGoals(): void +getGoals(): int 1. For the Player class: The goals data field must always be initialized to 0. - The no-arg constructor must read the name and number values from the user. Note that you must prompt the user with appropriate messages to enter the required values. The Player(name:String, number:int) constructor must initialized the name and number with values of corresponding parameters. The incrementGoals method must increment the player goals by 1. 2. For the Team class: The no-arg constructor must read the number of players from the user, and create the array players with a size that equals the entered number. Player objects must be created by invoking the no-arg constructor of the Player class. 1 The constructor Team(name:String, players: Player() must initialize the name with the passed parameter name, and initialize the array players using the corresponding passed array by creating a new array and new objects. The getPlayers method must return a reference to an array that represents a copy of the array players and whose objects are copies of the array players objects. The incrementPoints method must first check that the passed amount is 1 (draw-Jai) or 3 (win-J). If so, it increments the points data field with the valued passed in amount. If not, it must print "Failed to increment points!". 3. For the Group class: - The data field "matches" maintains the status of matches that must be played for this group as a two dimensional array. Each location represents a match with the team in the row being the host and the team in the column being the quest. A true value means that the match is played whereas a false value means that he match is not played yet. Note the diagonal doesn't contain actual matches since it links each team with itself, make sure that you skip it when your process this array. The constructor must initialize the array teams with 0 elements, and the boolean array matches such that it has numOfTeams rows and numOfTeams columns with all elements initialized to false. The addTeam method must add the team passed as an argument to the array teams. The printTeamsPoints method must print all the names of the teams in the group and their points in a table as follows: Team-Name Team-Points The unplayed Matches method must return the number of un-played matches for this group. The qualified Teams method must return in a String the names of the qualified teams J There are two qualified teams for each group which are the two teams with the greatest points. The String must contain the name of the team with the greatest points, then the team with the second greatest points comma separated: "team 1, team2". The playNextMatch method simulates playing a match as follows: a. It searches the array matches to find the next un-played match, searching must be performed row by row. When an un-played match is found, it registers the index of the host team (row) and the index of the quest team (column). Then set the array element to true to indicate that the match is played. b. It prints the following to the console: MATCH STARTED Host Team:...(team name)..... Guest Team:...(team name).... c. It It continuously prints the following menu to the console, and reads the user choice.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a Java program that implements the system shown in the following UML class diagram, which
represents a football championship:
Group
Team
teams: Team
matches: boolean[)
numOfTeams: int-4
name: String
- players: Player[]
- points: int
+ Group)
+ addTeam(team: Team): void
+ printTeamsPoints(): void
+ unplayedMatches(): int
+ qualifiedTeams(0:String
+ getNumofTeams)int
+ setNumofTeams(numOfTeams:int):void
+ playNextMatch(): Team
+ Team)
+ Team(name: String, players: Player[])
+ getPlayers():Player[]
+ incrementPoints(amount: int):void
+ getPoints():int
Player
+ name: String
+ number: int
- goals: int
+ Player()
+ Player(name: String, number:int)
+ incrementGoals(): void
+ getGoals(): int
1. For the Player class:
The goals data field must always be initialized to 0.
The no-arg constructor must read the name and number values from the user. Note that
you must prompt the user with appropriate messages to enter the required values.
The Player(name:String, number:int) constructor must initialized the name and number
with values of corresponding parameters.
The incrementGoals method must increment the player goals by 1.
2. For the Team class:
The no-arg constructor must read the number of players from the user, and create the
array players with a size that equals the entered number. Player objects must be created
by invoking the no-arg constructor of the Player class.
1
The constructor Team(name:String. players: Player[]) must initialize the name with the
passed parameter name, and initialize the array players using the corresponding passed
array by creating a new array and new objects.
The getPlayers method must return a reference to an array that represents a copy of the
array players and whose objects are copies of the array players objects.
The incrementPoints method must first check that the passed amount is 1 (draw - Jdai) or
3 (win - J). If so, it increments the points data field with the valued passed in amount. If
not, it must print "Failed to increment points!".
3. For the Group class:
The data field "matches" maintains the status of matches that must be played for this
group as a two dimensional array. Each location represents a match with the team i
row being the host and the team in the column being the quest. A true value means that
the match is played whereas a false value means that he match is not played yet. Note the
diagonal doesn't contain actual matches since it links each team with itself, make sure
that vou skip it when your process this array.
The constructor must initialize the array teams with 0 elements, and the boolean array
matches such that it has numofTeams rows and numofTeams columns with all elements
initialized to false.
The addTeam method must add the team passed as an argument to the array teams.
- The printTeamsPoints method must print all the names of the teams in the group and
their points in a table as follows:
the
Team-Name
Team-Points
The unplayedMatches method must return the number of un-played matches for this
group.
The qualifiedTeams method must return in a String the names of the qualified teams j
ali, There are two qualified teams for each group which are the two teams with the
greatest points. The String must contain the name of the team with the greatest points,
then the team with the second greatest points comma separated: "team1, team2".
The play NextMatch method simulates playing a match as follows:
a. It searches the array matches to find the next un-played match, searching must be
performed row by row. When an un-played match is found, it registers the index of
the host team (row) and the index of the quest team (column). Then set the array
element to true to indicate that the match is played.
b. It prints the following to the console:
МАТCH STARTED
Host Team: .....(team name)...
Guest Team: .....(team name)..
c. It continuously prints the following menu to the console, and reads the user choice.
What hannened?
Transcribed Image Text:Write a Java program that implements the system shown in the following UML class diagram, which represents a football championship: Group Team teams: Team matches: boolean[) numOfTeams: int-4 name: String - players: Player[] - points: int + Group) + addTeam(team: Team): void + printTeamsPoints(): void + unplayedMatches(): int + qualifiedTeams(0:String + getNumofTeams)int + setNumofTeams(numOfTeams:int):void + playNextMatch(): Team + Team) + Team(name: String, players: Player[]) + getPlayers():Player[] + incrementPoints(amount: int):void + getPoints():int Player + name: String + number: int - goals: int + Player() + Player(name: String, number:int) + incrementGoals(): void + getGoals(): int 1. For the Player class: The goals data field must always be initialized to 0. The no-arg constructor must read the name and number values from the user. Note that you must prompt the user with appropriate messages to enter the required values. The Player(name:String, number:int) constructor must initialized the name and number with values of corresponding parameters. The incrementGoals method must increment the player goals by 1. 2. For the Team class: The no-arg constructor must read the number of players from the user, and create the array players with a size that equals the entered number. Player objects must be created by invoking the no-arg constructor of the Player class. 1 The constructor Team(name:String. players: Player[]) must initialize the name with the passed parameter name, and initialize the array players using the corresponding passed array by creating a new array and new objects. The getPlayers method must return a reference to an array that represents a copy of the array players and whose objects are copies of the array players objects. The incrementPoints method must first check that the passed amount is 1 (draw - Jdai) or 3 (win - J). If so, it increments the points data field with the valued passed in amount. If not, it must print "Failed to increment points!". 3. For the Group class: The data field "matches" maintains the status of matches that must be played for this group as a two dimensional array. Each location represents a match with the team i row being the host and the team in the column being the quest. A true value means that the match is played whereas a false value means that he match is not played yet. Note the diagonal doesn't contain actual matches since it links each team with itself, make sure that vou skip it when your process this array. The constructor must initialize the array teams with 0 elements, and the boolean array matches such that it has numofTeams rows and numofTeams columns with all elements initialized to false. The addTeam method must add the team passed as an argument to the array teams. - The printTeamsPoints method must print all the names of the teams in the group and their points in a table as follows: the Team-Name Team-Points The unplayedMatches method must return the number of un-played matches for this group. The qualifiedTeams method must return in a String the names of the qualified teams j ali, There are two qualified teams for each group which are the two teams with the greatest points. The String must contain the name of the team with the greatest points, then the team with the second greatest points comma separated: "team1, team2". The play NextMatch method simulates playing a match as follows: a. It searches the array matches to find the next un-played match, searching must be performed row by row. When an un-played match is found, it registers the index of the host team (row) and the index of the quest team (column). Then set the array element to true to indicate that the match is played. b. It prints the following to the console: МАТCH STARTED Host Team: .....(team name)... Guest Team: .....(team name).. c. It continuously prints the following menu to the console, and reads the user choice. What hannened?
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY