|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--cardgame.Player
The Player class models an individual card player. A Player has a name and holds a hand of cards.
| Field Summary | |
private java.util.Vector |
hand
The private variable hand is a Java Vector that stores the PlayingCards that a Player is holding. |
private int |
money
The private variable money stores the amount of money a Player has at a given time. |
private java.lang.String |
name
The private variable name stores the name assigned to a Player. |
| Constructor Summary | |
Player()
The no-argument constructor creates a Player with the name "Unknown" and an zero initial amount of money. |
|
Player(java.lang.String playerName,
int initialMoney)
This constructor creates a Player with a specified name and initial amount of money. |
|
| Method Summary | |
boolean |
equals(Player theOtherPlayer)
The public method equals checks whether two Players are the same by testing whether the names are the same, returning a boolean result. |
int |
getMoney()
The public method getMoney retrieves the amount of money a Player currently has. |
java.lang.String |
getName()
The public method getName retrieves the name a Player is using for a game. |
java.lang.String |
getPlayerState()
The public method getPlayerState returns a useful String representation of the current state of a Player. |
void |
setMoney(int moneyAmount)
The public method setMoney specifies the amount of money a Player wins or loses. |
void |
setName(java.lang.String playerName)
The public method setName specifies the name a Player will use. |
java.lang.String |
toString()
The public method toString returns a complete specification of a Player's current state in a convenient tagged format. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private java.lang.String name
getName(),
setName(String playerName)private int money
getMoney(),
setMoney(int moneyAmount)private java.util.Vector hand
PlayingCard| Constructor Detail |
public Player()
name,
money
public Player(java.lang.String playerName,
int initialMoney)
playerName - the name a Player will use for a game.initialMoney - the initial amount of money a Player is given.name,
getName(),
setName(String playerName),
money,
getMoney(),
setMoney(int moneyAmount)| Method Detail |
public java.lang.String getName()
name,
setName(String playerName)public void setName(java.lang.String playerName)
playerName - the name a Player will use for a game.name,
getName()public int getMoney()
money,
setMoney(int moneyAmount)public void setMoney(int moneyAmount)
moneyAmount - the amount of money given to a Player.money,
getMoney()public java.lang.String getPlayerState()
public java.lang.String toString()
toString in class java.lang.Objectname,
moneypublic boolean equals(Player theOtherPlayer)
theOtherPlayer - the Player to be compared with this Player.name
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||