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()
GamegetGameName in interface Gamepublic void setGameName(String gameName)
GamesetGameName in interface GamegameName - Set the preferably unique game name.public GameCommandInterpreter getGameCommandInterpreter()
GamegetGameCommandInterpreter in interface GameGameCommandInterpreter instance.public void setGameCommandInterpreter(GameCommandInterpreter interpreter)
GameGame instance or set by the spring
container.setGameCommandInterpreter in interface Gameinterpreter - The interpreter instance to set.public Object unload()
GameGameRoom.close()Copyright © 2013. All Rights Reserved.