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.
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...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY