SlideShare a Scribd company logo
1 of 8
Download to read offline
Thanks so much for your help.
Review the GameService class. Notice the static variables holding the next identifier to be
assigned for game id, team id, and player id.
-Be sure you use the singleton pattern to adapt an ordinary class, so only one instance of the
GameService class can exist in memory at any given time. This can be done by creating unique
identifiers for each instance of game, team, and player.
-Game and team names must be unique to allow users to check whether a name is in use when
choosing a team name. Be sure that you use the iterator pattern to complete the addGame() and
getGame() methods.
-Create a base class called Entity. The Entity class must hold the common attributes and
behaviors as shown in the UML Diagram.
-Refactor the Game class to inherit from this new Entity class.
-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.
This is my current code:
// Game Service class:
package com.gamingroom;
import java.util.ArrayList;
import java.util.List;
/**
* A singleton service for the game engine
*
* @author coce@snhu.edu
*/
public class GameService {
/**
* A list of the active games
*/
private static List games = new ArrayList();
/*
* Holds the next game identifier
*/
private static long nextGameId = 1;
// FIXME: Add missing pieces to turn this class a singleton
/**
* Construct a new game instance
*
* @param name the unique name of the game
* @return the game instance (new or existing)
*/
// Creating a private instance of this class making it a singleton
private static GameService instance = new GameService();
// Private constructor to ensure we only have 1 instance
private void GameService() {
}
// Public accessor to allow outside classes to access this class
public static GameService getInstance() {
return instance;
}
public Game addGame(String name) {
// a local game instance
Game game = null;
// FIXME: Use iterator to look for existing game with same name
// if found, simply return the existing instance
for (Game currentGame : games) {
if (currentGame.getName().equals(name)) {
return currentGame;
}
}
// if not found, make a new game instance and add to list of games
if (game == null) {
game = new Game(nextGameId++, name);
games.add(game);
}
// return the new/existing game instance to the caller
return game;
}
/**
* Returns the game instance at the specified index.
*
* Scope is package/local for testing purposes.
*
* @param index index position in the list to return
* @return requested game instance
*/
Game getGame(int index) {
return games.get(index);
}
/**
* Returns the game instance with the specified id.
*
* @param id unique identifier of game to search for
* @return requested game instance
*/
public Game getGame(long id) {
// a local game instance
Game game = null;
// FIXME: Use iterator to look for existing game with same id
// if found, simply assign that instance to the local variable
for (Game currentGame : games) {
if (currentGame.getId() == id) {
game = currentGame;
}
}
return game;
}
/**
* Returns the game instance with the specified name.
*
* @param name unique name of game to search for
* @return requested game instance
*/
public Game getGame(String name) {
// a local game instance
Game game = null;
// FIXME: Use iterator to look for existing game with same name
// if found, simply assign that instance to the local variable
for (Game currentGame : games) {
if (currentGame.getName().equals(name)) {
game = currentGame;
}
}
return game;
}
/**
* Returns the number of games currently active
*
* @return the number of games currently active
*/
public int getGameCount() {
return games.size();
}
}
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------
//Game class :
package com.gamingroom;
/**
* A simple class to hold information about a game
*
*
* Notice the overloaded constructor that requires
* an id and name to be passed when creating.
* Also note that no mutators (setters) defined so
* these values cannot be changed once a game is
* created.
*
*
* @author coce@snhu.edu
*
*/
public class Game {
long id;
String name;
/**
* Hide the default constructor to prevent creating empty instances.
*/
private Game() {
}
/**
* Constructor with an identifier and name
*/
public Game(long 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;
}
@Override
public String toString() {
return "Game [id=" + id + ", name=" + name + "]";
}
}
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------
//Player class:
package com.gamingroom;
/**
* A simple class to hold information about a player
*
* Notice the overloaded constructor that requires
* an id and name to be passed when creating.
* Also note that no mutators (setters) defined so
* these values cannot be changed once a player is
* created.
*
* @author coce@snhu.edu
*
*/
public class Player {
long id;
String name;
/*
* Constructor with an identifier and name
*/
public Player(long 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 + "]";
}
}
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------
//Team class:
package com.gamingroom;
/**
* A simple class to hold information about a team
*
* Notice the overloaded constructor that requires
* an id and name to be passed when creating.
* Also note that no mutators (setters) defined so
* these values cannot be changed once a team is
* created.
*
* @author coce@snhu.edu
*
*/
public class Team {
long id;
String name;
/*
* Constructor with an identifier and name
*/
public Team(long 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 "Team [id=" + id + ", name=" + name + "]";
}
}

More Related Content

Similar to Thanks so much for your help. Review the GameService class. Noti.pdf

question.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfquestion.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfshahidqamar17
 
Here is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdfHere is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdftrishulinoverseas1
 
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdfHere is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdftrishulinoverseas1
 
Goal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfGoal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfaaicommunication34
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdfkavithaarp
 
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.pdfudit652068
 
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdfC++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdffazanmobiles
 
Use cases in the code with AOP
Use cases in the code with AOPUse cases in the code with AOP
Use cases in the code with AOPAndrzej Krzywda
 
import java.util.ArrayList; import java.util.Iterator; A.pdf
import java.util.ArrayList; import java.util.Iterator;   A.pdfimport java.util.ArrayList; import java.util.Iterator;   A.pdf
import java.util.ArrayList; import java.util.Iterator; A.pdfanushafashions
 
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docxsports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docxwhitneyleman54422
 
Create the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdfCreate the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdfpoblettesedanoree498
 
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)Pujana Paliyawan
 
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.pdfEvanpZjSandersony
 
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.pdfvishalateen
 
package com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfpackage com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfinfo430661
 
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 TilePUzzle class Anderson, Franceschi public class TilePu.docx TilePUzzle class Anderson, Franceschi public class TilePu.docx
TilePUzzle class Anderson, Franceschi public class TilePu.docxKomlin1
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfDEEPAKSONI562
 
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.pdfashishgargjaipuri
 

Similar to Thanks so much for your help. Review the GameService class. Noti.pdf (19)

question.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfquestion.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdf
 
Here is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdfHere is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdf
 
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdfHere is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
 
Goal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfGoal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdf
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
 
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
 
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdfC++ ProgrammingYou are to develop a program to read Baseball playe.pdf
C++ ProgrammingYou are to develop a program to read Baseball playe.pdf
 
Use cases in the code with AOP
Use cases in the code with AOPUse cases in the code with AOP
Use cases in the code with AOP
 
Save game function
Save game functionSave game function
Save game function
 
import java.util.ArrayList; import java.util.Iterator; A.pdf
import java.util.ArrayList; import java.util.Iterator;   A.pdfimport java.util.ArrayList; import java.util.Iterator;   A.pdf
import java.util.ArrayList; import java.util.Iterator; A.pdf
 
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docxsports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
 
Create the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdfCreate the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdf
 
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
 
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
 
package com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfpackage com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdf
 
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 TilePUzzle class Anderson, Franceschi public class TilePu.docx TilePUzzle class Anderson, Franceschi public class TilePu.docx
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
 
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
 

More from adwitanokiastore

The following table gives monthly data for four years in million ton.pdf
The following table gives monthly data for four years in million ton.pdfThe following table gives monthly data for four years in million ton.pdf
The following table gives monthly data for four years in million ton.pdfadwitanokiastore
 
the function of the endodermis is- to allow the uptake of nutrien.pdf
the function of the endodermis is- to allow the uptake of nutrien.pdfthe function of the endodermis is- to allow the uptake of nutrien.pdf
the function of the endodermis is- to allow the uptake of nutrien.pdfadwitanokiastore
 
The following questions address fraud risk factors and the assessmen.pdf
The following questions address fraud risk factors and the assessmen.pdfThe following questions address fraud risk factors and the assessmen.pdf
The following questions address fraud risk factors and the assessmen.pdfadwitanokiastore
 
The following statements about asset substitution are true except fo.pdf
The following statements about asset substitution are true except fo.pdfThe following statements about asset substitution are true except fo.pdf
The following statements about asset substitution are true except fo.pdfadwitanokiastore
 
The following is the adjusted trial balance for Stockton Company. St.pdf
The following is the adjusted trial balance for Stockton Company. St.pdfThe following is the adjusted trial balance for Stockton Company. St.pdf
The following is the adjusted trial balance for Stockton Company. St.pdfadwitanokiastore
 
The following data are available pertaining to Household Appliance C.pdf
The following data are available pertaining to Household Appliance C.pdfThe following data are available pertaining to Household Appliance C.pdf
The following data are available pertaining to Household Appliance C.pdfadwitanokiastore
 
the following code should print essential prime implicant but i does.pdf
the following code should print essential prime implicant but i does.pdfthe following code should print essential prime implicant but i does.pdf
the following code should print essential prime implicant but i does.pdfadwitanokiastore
 
The FBI raided President Trumps home in search of documents that th.pdf
The FBI raided President Trumps home in search of documents that th.pdfThe FBI raided President Trumps home in search of documents that th.pdf
The FBI raided President Trumps home in search of documents that th.pdfadwitanokiastore
 
The effect of the COVID-19 Pandemic in Australia. Australian autho.pdf
The effect of the COVID-19 Pandemic in Australia. Australian autho.pdfThe effect of the COVID-19 Pandemic in Australia. Australian autho.pdf
The effect of the COVID-19 Pandemic in Australia. Australian autho.pdfadwitanokiastore
 
The evidence on the relation between participation in the IMF lendin.pdf
The evidence on the relation between participation in the IMF lendin.pdfThe evidence on the relation between participation in the IMF lendin.pdf
The evidence on the relation between participation in the IMF lendin.pdfadwitanokiastore
 
The end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdf
The end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdfThe end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdf
The end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdfadwitanokiastore
 
The FBI wants to determine the effectiveness of their 10 Most Wanted.pdf
The FBI wants to determine the effectiveness of their 10 Most Wanted.pdfThe FBI wants to determine the effectiveness of their 10 Most Wanted.pdf
The FBI wants to determine the effectiveness of their 10 Most Wanted.pdfadwitanokiastore
 
The dollar rate of return on euro deposits isA the euro interest r.pdf
The dollar rate of return on euro deposits isA the euro interest r.pdfThe dollar rate of return on euro deposits isA the euro interest r.pdf
The dollar rate of return on euro deposits isA the euro interest r.pdfadwitanokiastore
 
The cost of an item of property, plant and equipment includes all of.pdf
The cost of an item of property, plant and equipment includes all of.pdfThe cost of an item of property, plant and equipment includes all of.pdf
The cost of an item of property, plant and equipment includes all of.pdfadwitanokiastore
 
The data set below summarizes F2 numbers from an F1 cross arising .pdf
The data set below summarizes F2 numbers from an F1 cross arising .pdfThe data set below summarizes F2 numbers from an F1 cross arising .pdf
The data set below summarizes F2 numbers from an F1 cross arising .pdfadwitanokiastore
 
The book value of equity of a firm at 31122020 is 2.000 million eu.pdf
The book value of equity of a firm at 31122020 is 2.000 million eu.pdfThe book value of equity of a firm at 31122020 is 2.000 million eu.pdf
The book value of equity of a firm at 31122020 is 2.000 million eu.pdfadwitanokiastore
 
The chance of a type 1 error is reduced byStatistically sign.pdf
The chance of a type 1 error is reduced byStatistically sign.pdfThe chance of a type 1 error is reduced byStatistically sign.pdf
The chance of a type 1 error is reduced byStatistically sign.pdfadwitanokiastore
 
The 1948 Declaration of Human Rights covers many areas of diversity .pdf
The 1948 Declaration of Human Rights covers many areas of diversity .pdfThe 1948 Declaration of Human Rights covers many areas of diversity .pdf
The 1948 Declaration of Human Rights covers many areas of diversity .pdfadwitanokiastore
 
Teslas Inc. Accrued liabilities1. Are operating liabilities lar.pdf
Teslas Inc. Accrued liabilities1. Are operating liabilities lar.pdfTeslas Inc. Accrued liabilities1. Are operating liabilities lar.pdf
Teslas Inc. Accrued liabilities1. Are operating liabilities lar.pdfadwitanokiastore
 
Tek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdf
Tek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdfTek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdf
Tek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdfadwitanokiastore
 

More from adwitanokiastore (20)

The following table gives monthly data for four years in million ton.pdf
The following table gives monthly data for four years in million ton.pdfThe following table gives monthly data for four years in million ton.pdf
The following table gives monthly data for four years in million ton.pdf
 
the function of the endodermis is- to allow the uptake of nutrien.pdf
the function of the endodermis is- to allow the uptake of nutrien.pdfthe function of the endodermis is- to allow the uptake of nutrien.pdf
the function of the endodermis is- to allow the uptake of nutrien.pdf
 
The following questions address fraud risk factors and the assessmen.pdf
The following questions address fraud risk factors and the assessmen.pdfThe following questions address fraud risk factors and the assessmen.pdf
The following questions address fraud risk factors and the assessmen.pdf
 
The following statements about asset substitution are true except fo.pdf
The following statements about asset substitution are true except fo.pdfThe following statements about asset substitution are true except fo.pdf
The following statements about asset substitution are true except fo.pdf
 
The following is the adjusted trial balance for Stockton Company. St.pdf
The following is the adjusted trial balance for Stockton Company. St.pdfThe following is the adjusted trial balance for Stockton Company. St.pdf
The following is the adjusted trial balance for Stockton Company. St.pdf
 
The following data are available pertaining to Household Appliance C.pdf
The following data are available pertaining to Household Appliance C.pdfThe following data are available pertaining to Household Appliance C.pdf
The following data are available pertaining to Household Appliance C.pdf
 
the following code should print essential prime implicant but i does.pdf
the following code should print essential prime implicant but i does.pdfthe following code should print essential prime implicant but i does.pdf
the following code should print essential prime implicant but i does.pdf
 
The FBI raided President Trumps home in search of documents that th.pdf
The FBI raided President Trumps home in search of documents that th.pdfThe FBI raided President Trumps home in search of documents that th.pdf
The FBI raided President Trumps home in search of documents that th.pdf
 
The effect of the COVID-19 Pandemic in Australia. Australian autho.pdf
The effect of the COVID-19 Pandemic in Australia. Australian autho.pdfThe effect of the COVID-19 Pandemic in Australia. Australian autho.pdf
The effect of the COVID-19 Pandemic in Australia. Australian autho.pdf
 
The evidence on the relation between participation in the IMF lendin.pdf
The evidence on the relation between participation in the IMF lendin.pdfThe evidence on the relation between participation in the IMF lendin.pdf
The evidence on the relation between participation in the IMF lendin.pdf
 
The end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdf
The end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdfThe end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdf
The end of bureaucracy Introduction Haier, based in Qingdao, Chi.pdf
 
The FBI wants to determine the effectiveness of their 10 Most Wanted.pdf
The FBI wants to determine the effectiveness of their 10 Most Wanted.pdfThe FBI wants to determine the effectiveness of their 10 Most Wanted.pdf
The FBI wants to determine the effectiveness of their 10 Most Wanted.pdf
 
The dollar rate of return on euro deposits isA the euro interest r.pdf
The dollar rate of return on euro deposits isA the euro interest r.pdfThe dollar rate of return on euro deposits isA the euro interest r.pdf
The dollar rate of return on euro deposits isA the euro interest r.pdf
 
The cost of an item of property, plant and equipment includes all of.pdf
The cost of an item of property, plant and equipment includes all of.pdfThe cost of an item of property, plant and equipment includes all of.pdf
The cost of an item of property, plant and equipment includes all of.pdf
 
The data set below summarizes F2 numbers from an F1 cross arising .pdf
The data set below summarizes F2 numbers from an F1 cross arising .pdfThe data set below summarizes F2 numbers from an F1 cross arising .pdf
The data set below summarizes F2 numbers from an F1 cross arising .pdf
 
The book value of equity of a firm at 31122020 is 2.000 million eu.pdf
The book value of equity of a firm at 31122020 is 2.000 million eu.pdfThe book value of equity of a firm at 31122020 is 2.000 million eu.pdf
The book value of equity of a firm at 31122020 is 2.000 million eu.pdf
 
The chance of a type 1 error is reduced byStatistically sign.pdf
The chance of a type 1 error is reduced byStatistically sign.pdfThe chance of a type 1 error is reduced byStatistically sign.pdf
The chance of a type 1 error is reduced byStatistically sign.pdf
 
The 1948 Declaration of Human Rights covers many areas of diversity .pdf
The 1948 Declaration of Human Rights covers many areas of diversity .pdfThe 1948 Declaration of Human Rights covers many areas of diversity .pdf
The 1948 Declaration of Human Rights covers many areas of diversity .pdf
 
Teslas Inc. Accrued liabilities1. Are operating liabilities lar.pdf
Teslas Inc. Accrued liabilities1. Are operating liabilities lar.pdfTeslas Inc. Accrued liabilities1. Are operating liabilities lar.pdf
Teslas Inc. Accrued liabilities1. Are operating liabilities lar.pdf
 
Tek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdf
Tek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdfTek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdf
Tek bir bamsz deiken i�eren bir regresyon modeline ________ de.pdf
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Thanks so much for your help. Review the GameService class. Noti.pdf

  • 1. Thanks so much for your help. Review the GameService class. Notice the static variables holding the next identifier to be assigned for game id, team id, and player id. -Be sure you use the singleton pattern to adapt an ordinary class, so only one instance of the GameService class can exist in memory at any given time. This can be done by creating unique identifiers for each instance of game, team, and player. -Game and team names must be unique to allow users to check whether a name is in use when choosing a team name. Be sure that you use the iterator pattern to complete the addGame() and getGame() methods. -Create a base class called Entity. The Entity class must hold the common attributes and behaviors as shown in the UML Diagram. -Refactor the Game class to inherit from this new Entity class. -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. This is my current code: // Game Service class: package com.gamingroom; import java.util.ArrayList; import java.util.List; /** * A singleton service for the game engine * * @author coce@snhu.edu */ public class GameService { /** * A list of the active games */ private static List games = new ArrayList(); /*
  • 2. * Holds the next game identifier */ private static long nextGameId = 1; // FIXME: Add missing pieces to turn this class a singleton /** * Construct a new game instance * * @param name the unique name of the game * @return the game instance (new or existing) */ // Creating a private instance of this class making it a singleton private static GameService instance = new GameService(); // Private constructor to ensure we only have 1 instance private void GameService() { } // Public accessor to allow outside classes to access this class public static GameService getInstance() { return instance; } public Game addGame(String name) { // a local game instance Game game = null; // FIXME: Use iterator to look for existing game with same name // if found, simply return the existing instance for (Game currentGame : games) { if (currentGame.getName().equals(name)) { return currentGame; } }
  • 3. // if not found, make a new game instance and add to list of games if (game == null) { game = new Game(nextGameId++, name); games.add(game); } // return the new/existing game instance to the caller return game; } /** * Returns the game instance at the specified index. * * Scope is package/local for testing purposes. * * @param index index position in the list to return * @return requested game instance */ Game getGame(int index) { return games.get(index); } /** * Returns the game instance with the specified id. * * @param id unique identifier of game to search for * @return requested game instance */ public Game getGame(long id) { // a local game instance Game game = null; // FIXME: Use iterator to look for existing game with same id // if found, simply assign that instance to the local variable for (Game currentGame : games) { if (currentGame.getId() == id) { game = currentGame;
  • 4. } } return game; } /** * Returns the game instance with the specified name. * * @param name unique name of game to search for * @return requested game instance */ public Game getGame(String name) { // a local game instance Game game = null; // FIXME: Use iterator to look for existing game with same name // if found, simply assign that instance to the local variable for (Game currentGame : games) { if (currentGame.getName().equals(name)) { game = currentGame; } } return game; } /** * Returns the number of games currently active * * @return the number of games currently active */ public int getGameCount() { return games.size(); } } --------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- //Game class : package com.gamingroom;
  • 5. /** * A simple class to hold information about a game * * * Notice the overloaded constructor that requires * an id and name to be passed when creating. * Also note that no mutators (setters) defined so * these values cannot be changed once a game is * created. * * * @author coce@snhu.edu * */ public class Game { long id; String name; /** * Hide the default constructor to prevent creating empty instances. */ private Game() { } /** * Constructor with an identifier and name */ public Game(long id, String name) { this(); this.id = id; this.name = name; } /** * @return the id */ public long getId() {
  • 6. return id; } /** * @return the name */ public String getName() { return name; } @Override public String toString() { return "Game [id=" + id + ", name=" + name + "]"; } } --------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- //Player class: package com.gamingroom; /** * A simple class to hold information about a player * * Notice the overloaded constructor that requires * an id and name to be passed when creating. * Also note that no mutators (setters) defined so * these values cannot be changed once a player is * created. * * @author coce@snhu.edu * */ public class Player { long id; String name;
  • 7. /* * Constructor with an identifier and name */ public Player(long 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 + "]"; } } --------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- //Team class: package com.gamingroom; /** * A simple class to hold information about a team * * Notice the overloaded constructor that requires * an id and name to be passed when creating. * Also note that no mutators (setters) defined so
  • 8. * these values cannot be changed once a team is * created. * * @author coce@snhu.edu * */ public class Team { long id; String name; /* * Constructor with an identifier and name */ public Team(long 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 "Team [id=" + id + ", name=" + name + "]"; } }