Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Background You are tasked with creating a system that manages the tennis player/team/tournament database. The system is menu driven. And the user can choose to:

Background You are tasked with creating a system that manages the tennis player/team/tournament database. The system is menu driven. And the user can choose to: 1. Display Loaded Players 2. Add Tournament 3. Add Team to Tournament 4. Display Team 5. Display Player 6. Display Tournament 7. Display Total Number of Teams 0. Quit The players are loaded into the system from a file at the start of running the program, and can not be changed once loaded. A player consists of its name, age and country code. A Team consists of a player and a manager. A tournament can carry up to max Teams registered (8 in this example), it has an id and a prize. A manager has a name. When a Team is added, a tournament must exist. A Team can only have one manager. A tournament can only be started if there is at least 2 Teams and the tournament exist. Create each class following the UML diagram, descriptions and tests. A test class is provided for you to test two of the classes as you develop. If the entire program does not work, a similar version will be used for marking. Hence it is VERY important to get each working individual before proceeding to the next to maximize potential marks and feedback. It is recommended you add to the tests provided or create your own tests, to cover all possible scenarios. You must use the attributes and methods provided in the UML diagrams and base template You can add private helper methods if you want to any class

Class1 Manager

package tennis;

public class Manager {

private String name;

public Manager(String name) { this.name = name; }

public String getName() { return (name); }

public String toString() { return ("Manager[ Name: " + name + " ]"); }

}

Class 2

package tennis;

public class Player {

private String name; private int age; private String countryCode;

public Player(String name, int age, String countryCode) { this.name = name; this.age = age; this.countryCode = countryCode; }

public String getName() { return (name); }

public int getAge() { return (age); }

public String getCountryCode() { return (countryCode); }

public String toString() { String desc = "Player[ name: " + name + ", age: " + age + ", country code: " + countryCode + " ]";

return desc; } }

Class3 Team

package tennis;

public class Team {

private String teamName; private static int totalNumOfTeams = 0; private Manager manager; private Player player;

public Team(String teamName, Player player) { this.teamName = teamName; this.player = player; this.manager = null; totalNumOfTeams++; }

public String getTeamName() { return teamName; }

public static int getTotalNumOfTeams() { return totalNumOfTeams; }

public Player getPlayer() { return (player); }

public Manager getManager() { if (manager != null) { return (manager); } else { return (null); } }

public boolean hasManager() { if (manager == null) { return (false); } else { return (true); } }

public void setManager(Manager manager) { if (this.manager == null) { this.manager = manager; } else { System.out.println("This team already has a manager."); } }

public String toString() { String description = "Team[ name: " + teamName + ", player: " + player.toString() + ", manager: ";

if (manager != null) { description += manager.toString(); } else { description += "No Manager "; }

description += "]"; return (description); }

}

And Complete the class4

package tennis;

public class Tournament {

private String tournamentID; private double prize; private Team[] teams; private int numTeamsRegistered; private final int MAX_TEAMS_REGISTERED = 8;

public Tournament(String tournamentID, double prize) { // TODO }

public String getTournamentID() { // TODO }

public int getNumTeamsRegistered() { // TODO }

public void registerTeam(Team team) { if (numTeamsRegistered

public Team getTeam(int index) { // TODO }

public Team[] getAllTeams() { Team[] teams_copy = new Team[MAX_TEAMS_REGISTERED]; for (int i = 0; i

public String toString() { // TODO } }

image text in transcribed

Class 4 Tournament.java Team - int tournamenti - double prize - Team[ ] Teams - int num Teams Registered - final int MAX_TEAMS_REGISTERED = 8; + Tournament(int tournamentID , double prize) + int getTournamentId() + int getNum Teams Registered() + Team getTeam(int index) + Team[] getAllTeams() + void registerTeam(Team Team) + String toString() Methods Team constructor Initializes tournament id based on value passed Initializes tournament prize based on value passed Set numTeamsRegistered to O Create the array Teams of length MAX_TEAMS_REGISTERED (in this example, 8 ) getNum Teams Registered, getTournamentID Accessors for specified attributes registerTeam Adds a Team based on value passed if there is room. The Teams array is filled from start to end The number of Teams on board is incremented when a Team is added getTeam Accessor for team at index getAllTeams Accessor for all teams to return an array of teams This needs to be done with no privacy leaks toString Returns String description of object (Format as shown in Example Output) Class 4 Tournament.java Team - int tournamenti - double prize - Team[ ] Teams - int num Teams Registered - final int MAX_TEAMS_REGISTERED = 8; + Tournament(int tournamentID , double prize) + int getTournamentId() + int getNum Teams Registered() + Team getTeam(int index) + Team[] getAllTeams() + void registerTeam(Team Team) + String toString() Methods Team constructor Initializes tournament id based on value passed Initializes tournament prize based on value passed Set numTeamsRegistered to O Create the array Teams of length MAX_TEAMS_REGISTERED (in this example, 8 ) getNum Teams Registered, getTournamentID Accessors for specified attributes registerTeam Adds a Team based on value passed if there is room. The Teams array is filled from start to end The number of Teams on board is incremented when a Team is added getTeam Accessor for team at index getAllTeams Accessor for all teams to return an array of teams This needs to be done with no privacy leaks toString Returns String description of object (Format as shown in Example Output)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago