|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--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. |
static int |
NUM_OF_TOKENS
Number of tokens which a Player flattens to. |
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 inString)
Constructor which creates a Player object from the flatten () method of another Player object. |
|
Player(String playerName,
PlayerState playerState)
Constructor requires both a player and a status as parameters and sets the seat number to NOT_SEATED. |
Method Summary | |
boolean |
canOfferDrawResign()
|
boolean |
canSit(PlayerList players)
Return true if a player can sit or not. |
boolean |
canStand(PlayerList players)
Returns true if a player can stand. |
boolean |
canStart(PlayerList players)
Returns true if a player can sit. |
String |
flatten()
Transmittable String representation of this object. |
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.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NUM_OF_TOKENS
public static final int NOT_SEATED
protected String playerName
protected int seatNum
protected PlayerState playerState
Constructor Detail |
public Player(String playerName, PlayerState playerState)
playerName
- playerState
- public Player(String inString) throws TransmissionException, NumberFormatException
inString
- TransmissionException
- NumberFormatException
- Method Detail |
public void sit()
public void stand()
public void start()
public boolean canSit(PlayerList players)
players
- List of all the player at a particular table.public boolean canStand(PlayerList players)
players
- List of all the player at a particular table.public boolean canStart(PlayerList players)
players
- List of all the player at a particular 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 String flatten()
flatten
in interface ITransmittable
ITransmittable.flatten()
public String toString()
toString
in class Object
Object.toString()
public PlayerState getState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |