public class SimpleGame extends Object implements Game
Game
interface so that simple games need not implement their own.
Note This implementation will throw exception if any of the setter
methods are invoked. All variables are final in this class and expected to be
set at object construction.Modifier and Type | Field and Description |
---|---|
private GameCommandInterpreter |
gameCommandInterpreter
Each game has its own specific commands.
|
private String |
gameName
The name of the game.
|
private Object |
id
This variable could be used as a database key.
|
Constructor and Description |
---|
SimpleGame(Object id,
String gameName) |
SimpleGame(Object id,
String gameName,
GameCommandInterpreter gameCommandInterpreter) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
GameCommandInterpreter |
getGameCommandInterpreter()
Each game requires a different set of game commands.
|
String |
getGameName()
Get the name of the game.
|
Object |
getId()
Meant as a database access key.
|
int |
hashCode() |
void |
setGameCommandInterpreter(GameCommandInterpreter interpreter)
Set the interpreter associated with this game.
|
void |
setGameName(String gameName)
Set the name of the game.
|
void |
setId(Object id)
Meant as a database access key.
|
Object |
unload()
Unloads the current game, by closing all sessions.
|
private final Object id
private final String gameName
private final GameCommandInterpreter gameCommandInterpreter
public SimpleGame(Object id, String gameName, GameCommandInterpreter gameCommandInterpreter)
public Object getId()
public void setId(Object id)
public String getGameName()
Game
getGameName
in interface Game
public void setGameName(String gameName)
Game
setGameName
in interface Game
gameName
- Set the preferably unique game name.public GameCommandInterpreter getGameCommandInterpreter()
Game
getGameCommandInterpreter
in interface Game
GameCommandInterpreter
instance.public void setGameCommandInterpreter(GameCommandInterpreter interpreter)
Game
Game
instance or set by the spring
container.setGameCommandInterpreter
in interface Game
interpreter
- The interpreter instance to set.public Object unload()
Game
GameRoom.close()
Copyright © 2013. All Rights Reserved.