Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I give the class team java code and a part of class4, plaease have me to complete the class 4 javacode Class Team package tennis;

I give the class team java code and a part of class4, plaease have me to complete the class 4 javacode

image text in transcribedimage text in transcribed

Class 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

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 } }

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: (to be done in Part 2) 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. (to be done Part 2) 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 Templates are provided for all classes required. A tester is provided for Team and Player classes. Three input files are provided Class 4 Tournament.java Team - int tournamentin - double prize - Team[ ] Teams int num Teams Registered - final int MAX TEAMS REGISTERED = 8; + Tournament(int tournamentis, double prize) + int getTournamentID() + int getNum TeamsRegistered() + 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 0 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

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago