|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable org.jogre.common.Player
This class contains information about a player, which is a user who has joined a table and wishes to play a game. Each Table object contains a list of Player objects.
This class contains the username of the player, their seat number (which is set when they sit down) and the state of the player (PlayerState) which uses the state design pattern as state can be quite complex.
This class also implements the ITransmittable interface which means it can be transferred across a network using the flatten() method.
Field Summary | |
static int |
NOT_SEATED
Constant to show that a player hasn't been seated. |
protected String |
playerName
Username of the user. |
protected PlayerState |
playerState
State of the player. |
protected int |
seatNum
Seat number of the user e.g. |
Constructor Summary | |
Player(String playerName,
PlayerState playerState)
Constructor requires both a player and a status as parameters and sets the seat number to NOT_SEATED. |
|
Player(XMLElement message)
Constructor which creates a Player object from the flatten () method of another Player object. |
Method Summary | |
boolean |
canOfferDrawResign()
REturn if it a player can offer a draw or resign a game. |
boolean |
canSit(Table table)
Return true if a player can sit or not. |
boolean |
canStand(Table table)
Returns true if a player can stand. |
boolean |
canStart(Table table)
Returns true if a player can sit. |
XMLElement |
flatten()
Transmittable String representation of this object (XML). |
String |
getPlayerName()
Return the username of this Player object. |
int |
getSeatNum()
Return the seat number of this player. |
PlayerState |
getState()
Returns the state of this player as a PlayerState object. |
String |
getStatusStr()
Returns the status of this player as a String. |
void |
setSeatNum(int seatNum)
Set the seat number of this player (set when a player sits down). |
void |
sit()
Player sits down at a table. |
void |
stand()
Player stands up from a table. |
void |
start()
Player decides to start. |
String |
toString()
String representation of this player. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NOT_SEATED
protected String playerName
protected int seatNum
protected PlayerState playerState
Constructor Detail |
public Player(String playerName, PlayerState playerState)
playerName
- Name of playerplayerState
- State of the playerpublic Player(XMLElement message)
message
- XML element version of object.Method Detail |
public void sit()
public void stand()
public void start()
public boolean canSit(Table table)
table
- Link to table
public boolean canStand(Table table)
table
- Link to table
public boolean canStart(Table table)
table
- Link to table
public boolean canOfferDrawResign()
public String getPlayerName()
public void setSeatNum(int seatNum)
seatNum
- Integer >= 0 and < maximum number of seats.public int getSeatNum()
public String getStatusStr()
public XMLElement flatten()
flatten
in interface ITransmittable
ITransmittable.flatten()
public String toString()
Object.toString()
public PlayerState getState()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |