Question: Does the attached code answer this question? Complete the code for the Player and Team classes. Each class must derive from the Entity class, as
Does the attached code answer this question?
Complete the code for the Player and Team classes. Each class must derive from the Entity class, as demonstrated in the UML diagram.
Every team and player must have a unique name by searching for the supplied name prior to adding the new instance. Use the iterator pattern in the addTeam and addPlayer methods.
public class Entity
private long id;
private String name;
public Entity
public Entitylong id String name
this.id id;
this.name name;
public long getId
return id;
public String getName
return name;
@Override
public String toString
return "Entity id id name name ;
public class Player extends Entity
long id;
String name;
Constructor with an identifier and name
public Playerlong id String name
this.id id;
this.name name;
@return the id
public long getId
return id;
@return the name
public String getName
return name;
@Override
public String toString
return "Player id id name name ;
public class Game extends Entity
long id;
String name;
Hide the default constructor to prevent creating empty instances.
private Game
Constructor with an identifier and name
public Gamelong id String name
this;
this.id id;
this.name name;
@return the id
public long getId
return id;
@return the name
public String getName
return name;
Creates and returns a new team object
public Team addTeamString name
Team team new TeamgetId name;
return team;
@Override
public String toString
return "Game id id name name ;
public class Team extends Entity
long id;
String name;
Constructor with an identifier and name
public Teamlong id String name
this.id id;
this.name name;
@return the id
public long getId
return id;
@return the name
public String getName
return name;
method for the creation of a player object, returns the player
public Player addPlayerString name
Player player new PlayergetId name;
return player;
@Override
public String toString
return "Team id id name name ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
