SlideShare a Scribd company logo
1 of 11
Download to read offline
3.1. Coach class
For this class you only need to implement two constructors; the overloaded and copy constructor
in addition to the static factory methods.
3.2. Player class
Two types of the constructors (overloaded and copy) and all the setter and getter methods is what
you need to implement for this task. Also, you should implement the static factory methods.
3.3. Soccer Team class
Three types of the constructors (default, overloaded and copy) and all the setter and getter
methods plus the static factory methods is what you need to implement for this task.
Please note that the instance variables in this class are all private, as the UML shows.
/**
* This class implements a simple soccer team
*@author May Haidar
*/
public class SoccerTeam {
/**
* This is the default constructors.
* At most 11 player can play this team.
* At most there are 4 roles players can have.
*/
private SoccerTeam() {
}
/**
* This is the overloaded constructor for this class
* @param player is an array containing all the players who entered the team.
* @param coach is the area that is available to the players to play.
*/
private SoccerTeam (Player [] player, Coach coach) {
}
/**
* This the copy constructor for this class
* @param team is an object of SoccerTeam, whose component is deeply copied into
* the component of this object.
*/
private SoccerTeam (SoccerTeam team) {
}
/**
* This is a static factory method
* @return IT returns an object of SoccerTeam
*/
public static SoccerTeam getInstance() {
}
/**
* This is a static factory method
* @param player is an array that contains players.
* @param coach is a coach of the team
* @return It returns an object of SoccerTeam made using the input parameters.
*/
public static SoccerTeam getInstance(Player [] player, Coach coach) {
}
/**
* This is a static factory method
* @param team is an object of SoccerTeam
* @return it returns an object of SoccerTeam made using the input parameter.
*/
public static SoccerTeam getInstance(SoccerTeam team) {
}
/**
* This is the getter method for the player list.
* @return returns an array containing all the players of this team.
*/
public Player[] getPlayers() {
}
/**
* This is the getter method for the coach attribute.
* @return Returns an object of coach containing all the components of this team's coach.
*/
public Coach getCoach() {
}
/**
* This is the setter method for the player attribute, which deeply copies
* the input parameter into the player attribute of this object.
* @param player is an array of Player, whose elements are copied in the player attribute of this
object.
*/
public void setPlayers(Player [] player) {
}
/**
* This is the setter method for the coach attribute, which deeply copies
* the input parameter into the coach attribute of this object.
* @param coach is an object of Coach, whose attributes are copied in the coach attribute of this
object.
*/
public void setCoach(Coach coach) {
}
}
/**
*
* This class implements all a player requires to play in this team.
* A player has a number, a name, and a role. A role can be either defense, central, striker, or goal
keeper.
* these roles can be represented by the characters 'd', 'c', 's', or 'g'
*
*/
class Player {
/**
* This is the overloaded constructor for this class
* @param name
* @param role
*/
private Player(int num, String name, char role) {
}
/**
* This is the copy constructor for this class
* @param player
*/
private Player(Player player) {
}
/**
* This is a static factory method.
* @return It returns an object of Player
*/
public static Player getInstance() {
}
/**
* This is a static factory method
* @param name is the name of player
* @param role is the role of the player in the team
* @return It returns an object of player, which is made by the two input variables.
*/
public static Player getInstance(int num, String name, char role) {
}
/**
* This is a static factory method
* @param player is an object of player
* @return it returns an object of player that is made using the input parameter.
*/
public static Player getInstance(Player player) {
}
/**
* This is the getter method for attribute name
* @return returns the value of attribute name
*/
public String getName() {
}
/**
* This is the getter method for attribute role
* @return returns the reference to attribute role.
*/
public char getRole() {
}
/**
* This is the setter method for attribute name
* @param name is the value that is used to initialize name attribute
*/
public void setName(String name) {
}
/**
* This is the setter method for attribute role
* @param role is the object, whose reference is used to initialize attribute role.
*/
public void setRole(char role) {
}
}
/**
* This class represents the coach who coaches the team.
*
*/
class Coach{
/**
* This is the overloaded constructor.
* @param name is the first area in which player can play.
* @param yearsExp is the second area in which player can play.
* @param level is the third area in which player can play.
* @param airShip is the fourth area in which player can play.
*/
private Coach(String name, int yearsExp, String level) {
}
/**
* This is a static factory method that initializes the attributes to their default values.
* @return It returns an object of MAP
*/
public static Coach getInstance() {
}
/**
* This is a static factory method
* @param name is the first area in which player can play.
* @param yearsExp is the second area in which player can play.
* @param level is the third area in which player can play.
* @param airShip is the fourth area in which player can play.
* @return it returns an object of MAP.
*/
public static Coach getInstance(String name, int yearsExp, String level) {
}
/**
* This is the copy constructor.
* @param coach is an object of Coach that is used to initialize this object.
*/
private Coach(Coach coach) {
}
public static Coach getInstance(Coach coach) {
}
}
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class SoccerTeamTest {
@Test
void testCoach1() {
Coach coach = Coach.getInstance();
boolean expected = true;
boolean actual = (coach.name.compareTo("") == 0) && (coach.yearsExp == 0)
&& (coach.level.compareTo("") == 0);
assertEquals(actual, expected, "The coach is not initialized correctly by the default constructor of
the Coach class.");
}
@Test
void testCoach2() {
Coach coach = Coach.getInstance("Xavi", 20, "high");
boolean expected = true;
boolean actual = (coach.name.compareTo("Xavi") == 0) && (coach.yearsExp == 20) &&
(coach.level.compareTo("high") == 0);
assertEquals(actual, expected, "The coach is not initialized correctly by the overloaded constructor
of the Coach class.");
}
@Test
void testCoach3() {
Coach coach1 = Coach.getInstance("Benni", 10, "beginner");
Coach coach2 = Coach.getInstance(coach1);
boolean expected = true;
boolean actual = (coach1.name.compareTo(coach2.name) == 0) && (coach1.yearsExp ==
coach2.yearsExp) &&
(coach1.level.compareTo(coach2.level) == 0);
assertEquals(actual, expected, "The coach is not initialized correctly by the copy constructor of the
Coach class.");
}
@Test
void testPlayer1() {
Player player = Player.getInstance(1, "Messi", 's');
char role ='s';
boolean expected = true;
boolean actual = (role == player.getRole());
assertEquals(actual, expected, "The aggregation relationship is not correcly implemented for the
Player class [wrong getter method].");
}
@Test
void testPlayer2() {
char role = 'g';
Player player = Player.getInstance();
player.setRole(role);
boolean expected = true;
boolean actual = (role == player.role);
assertEquals(actual, expected, "The aggregation relationship is not correcly implemented for the
Player class.[wrong setter method]");
}
@Test
void testPlayer3() {
char role = 'd';
Player player1 = Player.getInstance(2, "Ronaldo", role);
Player player2 = Player.getInstance(player1);
boolean expected = true;
boolean actual = (player1.getRole() == player2.getRole()) && (player2.getRole() == role);
assertEquals(actual, expected, "The aggregation relationship is not correcly implemented in the
copy constructor, for role attribute in Player class.");
}
@Test
void testPlayer4() {
char role = 'c';
Player player1 = Player.getInstance(3, "Benzema", role);
Player player2 = Player.getInstance(3, "Benzema", role);
boolean expected = true;
boolean actual = (player1.getName() == player2.getName());
assertEquals(actual, expected, "The aggregation relationship is not correctly implemented for
name in Player class.");
}
@Test
void testPlayer5() {
char role = 'g';
Player player1 = Player.getInstance(10, new String("Casillas"), role);
Player player2 = Player.getInstance(10, "Casillas", role);
boolean expected = true;
boolean actual = (player1.getName() != player2.getName());
assertEquals(actual, expected, "The aggregation relationship is not correctly implemented for
name in Player class.");
}
@Test
void testSoccerTeam1() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance();
SoccerTeam team = SoccerTeam.getInstance(players, coach);
boolean expected = true;
boolean actual = (team.getPlayers() != players);
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for the
player list in SoccerTeam class [getPlayer].");
}
@Test
void testSoccerTeam2() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance("Xavi", 20, "high");
SoccerTeam team = SoccerTeam.getInstance(players, coach);
boolean expected = true;
boolean actual = (team.getCoach() != coach);
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for the
coach attribute in SoccerTeam class [getCoach].");
}
@Test
void testSoccerTeam3() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance("Xavi", 20, "high");
SoccerTeam team = SoccerTeam.getInstance();
team.setCoach(coach);
team.setPlayers(players);
boolean expected = true;
boolean actual = (team.getCoach() != coach) && (team.getPlayers() != players);
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for
coach in SoccerTeam class [setCoach and setPlayer].");
}
@Test
void testSoccerTeam4() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance("Xavi", 20, "high");
SoccerTeam team = SoccerTeam.getInstance();
team.setCoach(coach);
team.setPlayers(players);
boolean expected = true;
boolean actual = (team.getCoach().level != coach.level);
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for
coach in SoccerTeam class [setCoach].");
}
@Test
void testSoccerTeam5() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance("Xavi", 20, "high");
SoccerTeam team = SoccerTeam.getInstance();
team.setCoach(coach);
team.setPlayers(players);
boolean expected = true;
boolean actual = (team.getPlayers()[0].name != players[0].name);
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for
coach in SoccerTeam class [setPlayer].");
}
@Test
void testSoccerTeam6() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance("Xavi", 20, "high");
SoccerTeam team1 = SoccerTeam.getInstance(players, coach);
SoccerTeam team2 = SoccerTeam.getInstance(players, coach);
boolean expected = true;
boolean actual = (team1.getPlayers() != team2.getPlayers());
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for
player array in SoccerTeam class [copy constructor or overloaded constructor].");
}
@Test
void testSoccerTeam7() {
Player player1 = Player.getInstance(1, "Messi", 's');
Player player2 = Player.getInstance(2, "Neymar", 'd');
Player [] players = new Player[2];
players[0] = player1;
players[1] = player2;
Coach coach = Coach.getInstance("Xavi", 20, "high");
SoccerTeam team1 = SoccerTeam.getInstance(players, coach);
SoccerTeam team2 = SoccerTeam.getInstance(players, coach);
boolean expected = true;
boolean actual = (team1.getCoach() != team2.getCoach());
assertEquals(actual, expected, "The Composition relationship is not correctly implemented for
coach in SoccerTeam class [copy constructor or overloaded constructor].");
}
}

More Related Content

Similar to 31 Coach class For this class you only need to implement .pdf

VideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdfVideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdf
annaistrvlr
 
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdfInheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
EvanpZjSandersony
 
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdfInheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
vishalateen
 
Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdf
Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdfUse Netbeans to copy your last lab (Lab 07) to a new project called La.pdf
Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdf
ashishgargjaipuri
 
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdfSuggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
ssuser58be4b1
 
Please fix my errors class Iterator public Construc.pdf
Please fix my errors   class Iterator  public  Construc.pdfPlease fix my errors   class Iterator  public  Construc.pdf
Please fix my errors class Iterator public Construc.pdf
kitty811
 
CS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docx
CS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docxCS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docx
CS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docx
annettsparrow
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
sooryasalini
 
public class Team {Attributes private String teamId; private.pdf
public class Team {Attributes private String teamId; private.pdfpublic class Team {Attributes private String teamId; private.pdf
public class Team {Attributes private String teamId; private.pdf
anushasarees
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
ankitmobileshop235
 
Please use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdfPlease use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdf
admin463580
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
aquadreammail
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
aplolomedicalstoremr
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Ankitchhabra28
 

Similar to 31 Coach class For this class you only need to implement .pdf (20)

VideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdfVideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdf
 
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdfInheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
 
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdfInheritance - Creating a Multilevel Hierarchy  In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript
 
Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdf
Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdfUse Netbeans to copy your last lab (Lab 07) to a new project called La.pdf
Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdf
 
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdfSuggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
 
Please fix my errors class Iterator public Construc.pdf
Please fix my errors   class Iterator  public  Construc.pdfPlease fix my errors   class Iterator  public  Construc.pdf
Please fix my errors class Iterator public Construc.pdf
 
CS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docx
CS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docxCS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docx
CS117-S18-AlharbiMohammed-master.gitignore.class.ctxt..docx
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
 
public class Team {Attributes private String teamId; private.pdf
public class Team {Attributes private String teamId; private.pdfpublic class Team {Attributes private String teamId; private.pdf
public class Team {Attributes private String teamId; private.pdf
 
Operator overload rr
Operator overload  rrOperator overload  rr
Operator overload rr
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Please use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdfPlease use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdf
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Overloading
OverloadingOverloading
Overloading
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 

More from AASTHASTYLETRADITION

Vaka almas hakknda bir rapor yazn I Format Gereksinimler.pdf
Vaka almas hakknda bir rapor yazn  I Format Gereksinimler.pdfVaka almas hakknda bir rapor yazn  I Format Gereksinimler.pdf
Vaka almas hakknda bir rapor yazn I Format Gereksinimler.pdf
AASTHASTYLETRADITION
 
Unilever es una multinacional angloholandesa de bienes de co.pdf
Unilever es una multinacional angloholandesa de bienes de co.pdfUnilever es una multinacional angloholandesa de bienes de co.pdf
Unilever es una multinacional angloholandesa de bienes de co.pdf
AASTHASTYLETRADITION
 

More from AASTHASTYLETRADITION (20)

________ es la tasa de descuento o tasa interna de rendimien.pdf
________ es la tasa de descuento o tasa interna de rendimien.pdf________ es la tasa de descuento o tasa interna de rendimien.pdf
________ es la tasa de descuento o tasa interna de rendimien.pdf
 
Which one of the following statements is NOT correct a A c.pdf
Which one of the following statements is NOT correct a A c.pdfWhich one of the following statements is NOT correct a A c.pdf
Which one of the following statements is NOT correct a A c.pdf
 
Which of the following processes is most similar to the proc.pdf
Which of the following processes is most similar to the proc.pdfWhich of the following processes is most similar to the proc.pdf
Which of the following processes is most similar to the proc.pdf
 
What are different kinds of perception biases in the workpla.pdf
What are different kinds of perception biases in the workpla.pdfWhat are different kinds of perception biases in the workpla.pdf
What are different kinds of perception biases in the workpla.pdf
 
Vaka almas hakknda bir rapor yazn I Format Gereksinimler.pdf
Vaka almas hakknda bir rapor yazn  I Format Gereksinimler.pdfVaka almas hakknda bir rapor yazn  I Format Gereksinimler.pdf
Vaka almas hakknda bir rapor yazn I Format Gereksinimler.pdf
 
use a commercial passenger airline company to illustrate a s.pdf
use a commercial passenger airline company to illustrate a s.pdfuse a commercial passenger airline company to illustrate a s.pdf
use a commercial passenger airline company to illustrate a s.pdf
 
Using Bowens Reaction Series how does the silicate structu.pdf
Using Bowens Reaction Series how does the silicate structu.pdfUsing Bowens Reaction Series how does the silicate structu.pdf
Using Bowens Reaction Series how does the silicate structu.pdf
 
Unilever es una multinacional angloholandesa de bienes de co.pdf
Unilever es una multinacional angloholandesa de bienes de co.pdfUnilever es una multinacional angloholandesa de bienes de co.pdf
Unilever es una multinacional angloholandesa de bienes de co.pdf
 
Un proceso de elaboracin de presupuestos en el que las pers.pdf
Un proceso de elaboracin de presupuestos en el que las pers.pdfUn proceso de elaboracin de presupuestos en el que las pers.pdf
Un proceso de elaboracin de presupuestos en el que las pers.pdf
 
Un correo electrnico inapropiado Roger Miller director de.pdf
Un correo electrnico inapropiado  Roger Miller director de.pdfUn correo electrnico inapropiado  Roger Miller director de.pdf
Un correo electrnico inapropiado Roger Miller director de.pdf
 
Todos los siguientes son ejemplos de generadores de costos d.pdf
Todos los siguientes son ejemplos de generadores de costos d.pdfTodos los siguientes son ejemplos de generadores de costos d.pdf
Todos los siguientes son ejemplos de generadores de costos d.pdf
 
The probability that a person responds to a mailed questionn.pdf
The probability that a person responds to a mailed questionn.pdfThe probability that a person responds to a mailed questionn.pdf
The probability that a person responds to a mailed questionn.pdf
 
The following is true about the Balance Sheet I Net Fixed .pdf
The following is true about the Balance Sheet I Net Fixed .pdfThe following is true about the Balance Sheet I Net Fixed .pdf
The following is true about the Balance Sheet I Net Fixed .pdf
 
The American Red Cross has isssued statements indicating tha.pdf
The American Red Cross has isssued statements indicating tha.pdfThe American Red Cross has isssued statements indicating tha.pdf
The American Red Cross has isssued statements indicating tha.pdf
 
Students will build a virtual digital forensics lab for the .pdf
Students will build a virtual digital forensics lab for the .pdfStudents will build a virtual digital forensics lab for the .pdf
Students will build a virtual digital forensics lab for the .pdf
 
Should countries like the US Canada and the UK allow Chin.pdf
Should countries like the US Canada and the UK allow Chin.pdfShould countries like the US Canada and the UK allow Chin.pdf
Should countries like the US Canada and the UK allow Chin.pdf
 
SCENARIO A small manufacturing company with a limited Inform.pdf
SCENARIO A small manufacturing company with a limited Inform.pdfSCENARIO A small manufacturing company with a limited Inform.pdf
SCENARIO A small manufacturing company with a limited Inform.pdf
 
Question A Company may raise capital by granting fixed and .pdf
Question A Company may raise capital by granting fixed and .pdfQuestion A Company may raise capital by granting fixed and .pdf
Question A Company may raise capital by granting fixed and .pdf
 
Pregunta 4 La relacin entre bpendiente y rcoeficiente de.pdf
Pregunta 4  La relacin entre bpendiente y rcoeficiente de.pdfPregunta 4  La relacin entre bpendiente y rcoeficiente de.pdf
Pregunta 4 La relacin entre bpendiente y rcoeficiente de.pdf
 
Organic molecule Digested by what enzyme Monomers produce.pdf
Organic molecule Digested by what enzyme Monomers produce.pdfOrganic molecule Digested by what enzyme Monomers produce.pdf
Organic molecule Digested by what enzyme Monomers produce.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 

31 Coach class For this class you only need to implement .pdf

  • 1. 3.1. Coach class For this class you only need to implement two constructors; the overloaded and copy constructor in addition to the static factory methods. 3.2. Player class Two types of the constructors (overloaded and copy) and all the setter and getter methods is what you need to implement for this task. Also, you should implement the static factory methods. 3.3. Soccer Team class Three types of the constructors (default, overloaded and copy) and all the setter and getter methods plus the static factory methods is what you need to implement for this task. Please note that the instance variables in this class are all private, as the UML shows. /** * This class implements a simple soccer team *@author May Haidar */ public class SoccerTeam { /** * This is the default constructors. * At most 11 player can play this team. * At most there are 4 roles players can have. */ private SoccerTeam() { } /** * This is the overloaded constructor for this class * @param player is an array containing all the players who entered the team. * @param coach is the area that is available to the players to play. */ private SoccerTeam (Player [] player, Coach coach) { } /** * This the copy constructor for this class * @param team is an object of SoccerTeam, whose component is deeply copied into * the component of this object. */ private SoccerTeam (SoccerTeam team) { }
  • 2. /** * This is a static factory method * @return IT returns an object of SoccerTeam */ public static SoccerTeam getInstance() { } /** * This is a static factory method * @param player is an array that contains players. * @param coach is a coach of the team * @return It returns an object of SoccerTeam made using the input parameters. */ public static SoccerTeam getInstance(Player [] player, Coach coach) { } /** * This is a static factory method * @param team is an object of SoccerTeam * @return it returns an object of SoccerTeam made using the input parameter. */ public static SoccerTeam getInstance(SoccerTeam team) { } /** * This is the getter method for the player list. * @return returns an array containing all the players of this team. */ public Player[] getPlayers() { } /** * This is the getter method for the coach attribute. * @return Returns an object of coach containing all the components of this team's coach. */ public Coach getCoach() { } /**
  • 3. * This is the setter method for the player attribute, which deeply copies * the input parameter into the player attribute of this object. * @param player is an array of Player, whose elements are copied in the player attribute of this object. */ public void setPlayers(Player [] player) { } /** * This is the setter method for the coach attribute, which deeply copies * the input parameter into the coach attribute of this object. * @param coach is an object of Coach, whose attributes are copied in the coach attribute of this object. */ public void setCoach(Coach coach) { } } /** * * This class implements all a player requires to play in this team. * A player has a number, a name, and a role. A role can be either defense, central, striker, or goal keeper. * these roles can be represented by the characters 'd', 'c', 's', or 'g' * */ class Player { /** * This is the overloaded constructor for this class * @param name * @param role */ private Player(int num, String name, char role) { } /** * This is the copy constructor for this class * @param player */ private Player(Player player) {
  • 4. } /** * This is a static factory method. * @return It returns an object of Player */ public static Player getInstance() { } /** * This is a static factory method * @param name is the name of player * @param role is the role of the player in the team * @return It returns an object of player, which is made by the two input variables. */ public static Player getInstance(int num, String name, char role) { } /** * This is a static factory method * @param player is an object of player * @return it returns an object of player that is made using the input parameter. */ public static Player getInstance(Player player) { } /** * This is the getter method for attribute name * @return returns the value of attribute name */ public String getName() { } /** * This is the getter method for attribute role * @return returns the reference to attribute role. */ public char getRole() { } /**
  • 5. * This is the setter method for attribute name * @param name is the value that is used to initialize name attribute */ public void setName(String name) { } /** * This is the setter method for attribute role * @param role is the object, whose reference is used to initialize attribute role. */ public void setRole(char role) { } } /** * This class represents the coach who coaches the team. * */ class Coach{ /** * This is the overloaded constructor. * @param name is the first area in which player can play. * @param yearsExp is the second area in which player can play. * @param level is the third area in which player can play. * @param airShip is the fourth area in which player can play. */ private Coach(String name, int yearsExp, String level) { } /** * This is a static factory method that initializes the attributes to their default values. * @return It returns an object of MAP */ public static Coach getInstance() { } /** * This is a static factory method
  • 6. * @param name is the first area in which player can play. * @param yearsExp is the second area in which player can play. * @param level is the third area in which player can play. * @param airShip is the fourth area in which player can play. * @return it returns an object of MAP. */ public static Coach getInstance(String name, int yearsExp, String level) { } /** * This is the copy constructor. * @param coach is an object of Coach that is used to initialize this object. */ private Coach(Coach coach) { } public static Coach getInstance(Coach coach) { } } import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class SoccerTeamTest { @Test void testCoach1() { Coach coach = Coach.getInstance(); boolean expected = true; boolean actual = (coach.name.compareTo("") == 0) && (coach.yearsExp == 0) && (coach.level.compareTo("") == 0); assertEquals(actual, expected, "The coach is not initialized correctly by the default constructor of the Coach class."); } @Test void testCoach2() { Coach coach = Coach.getInstance("Xavi", 20, "high"); boolean expected = true; boolean actual = (coach.name.compareTo("Xavi") == 0) && (coach.yearsExp == 20) && (coach.level.compareTo("high") == 0); assertEquals(actual, expected, "The coach is not initialized correctly by the overloaded constructor
  • 7. of the Coach class."); } @Test void testCoach3() { Coach coach1 = Coach.getInstance("Benni", 10, "beginner"); Coach coach2 = Coach.getInstance(coach1); boolean expected = true; boolean actual = (coach1.name.compareTo(coach2.name) == 0) && (coach1.yearsExp == coach2.yearsExp) && (coach1.level.compareTo(coach2.level) == 0); assertEquals(actual, expected, "The coach is not initialized correctly by the copy constructor of the Coach class."); } @Test void testPlayer1() { Player player = Player.getInstance(1, "Messi", 's'); char role ='s'; boolean expected = true; boolean actual = (role == player.getRole()); assertEquals(actual, expected, "The aggregation relationship is not correcly implemented for the Player class [wrong getter method]."); } @Test void testPlayer2() { char role = 'g'; Player player = Player.getInstance(); player.setRole(role); boolean expected = true; boolean actual = (role == player.role); assertEquals(actual, expected, "The aggregation relationship is not correcly implemented for the Player class.[wrong setter method]"); } @Test void testPlayer3() { char role = 'd'; Player player1 = Player.getInstance(2, "Ronaldo", role); Player player2 = Player.getInstance(player1); boolean expected = true; boolean actual = (player1.getRole() == player2.getRole()) && (player2.getRole() == role); assertEquals(actual, expected, "The aggregation relationship is not correcly implemented in the copy constructor, for role attribute in Player class."); }
  • 8. @Test void testPlayer4() { char role = 'c'; Player player1 = Player.getInstance(3, "Benzema", role); Player player2 = Player.getInstance(3, "Benzema", role); boolean expected = true; boolean actual = (player1.getName() == player2.getName()); assertEquals(actual, expected, "The aggregation relationship is not correctly implemented for name in Player class."); } @Test void testPlayer5() { char role = 'g'; Player player1 = Player.getInstance(10, new String("Casillas"), role); Player player2 = Player.getInstance(10, "Casillas", role); boolean expected = true; boolean actual = (player1.getName() != player2.getName()); assertEquals(actual, expected, "The aggregation relationship is not correctly implemented for name in Player class."); } @Test void testSoccerTeam1() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1; players[1] = player2; Coach coach = Coach.getInstance(); SoccerTeam team = SoccerTeam.getInstance(players, coach); boolean expected = true; boolean actual = (team.getPlayers() != players); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for the player list in SoccerTeam class [getPlayer]."); } @Test void testSoccerTeam2() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1;
  • 9. players[1] = player2; Coach coach = Coach.getInstance("Xavi", 20, "high"); SoccerTeam team = SoccerTeam.getInstance(players, coach); boolean expected = true; boolean actual = (team.getCoach() != coach); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for the coach attribute in SoccerTeam class [getCoach]."); } @Test void testSoccerTeam3() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1; players[1] = player2; Coach coach = Coach.getInstance("Xavi", 20, "high"); SoccerTeam team = SoccerTeam.getInstance(); team.setCoach(coach); team.setPlayers(players); boolean expected = true; boolean actual = (team.getCoach() != coach) && (team.getPlayers() != players); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for coach in SoccerTeam class [setCoach and setPlayer]."); } @Test void testSoccerTeam4() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1; players[1] = player2; Coach coach = Coach.getInstance("Xavi", 20, "high"); SoccerTeam team = SoccerTeam.getInstance(); team.setCoach(coach); team.setPlayers(players); boolean expected = true; boolean actual = (team.getCoach().level != coach.level); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for coach in SoccerTeam class [setCoach].");
  • 10. } @Test void testSoccerTeam5() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1; players[1] = player2; Coach coach = Coach.getInstance("Xavi", 20, "high"); SoccerTeam team = SoccerTeam.getInstance(); team.setCoach(coach); team.setPlayers(players); boolean expected = true; boolean actual = (team.getPlayers()[0].name != players[0].name); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for coach in SoccerTeam class [setPlayer]."); } @Test void testSoccerTeam6() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1; players[1] = player2; Coach coach = Coach.getInstance("Xavi", 20, "high"); SoccerTeam team1 = SoccerTeam.getInstance(players, coach); SoccerTeam team2 = SoccerTeam.getInstance(players, coach); boolean expected = true; boolean actual = (team1.getPlayers() != team2.getPlayers()); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for player array in SoccerTeam class [copy constructor or overloaded constructor]."); } @Test void testSoccerTeam7() { Player player1 = Player.getInstance(1, "Messi", 's'); Player player2 = Player.getInstance(2, "Neymar", 'd'); Player [] players = new Player[2]; players[0] = player1; players[1] = player2; Coach coach = Coach.getInstance("Xavi", 20, "high");
  • 11. SoccerTeam team1 = SoccerTeam.getInstance(players, coach); SoccerTeam team2 = SoccerTeam.getInstance(players, coach); boolean expected = true; boolean actual = (team1.getCoach() != team2.getCoach()); assertEquals(actual, expected, "The Composition relationship is not correctly implemented for coach in SoccerTeam class [copy constructor or overloaded constructor]."); } }