Class Player

java.lang.Object
  extended by Player

public class Player
extends java.lang.Object

The Player class manages a Player and her winnings.

Author:
willb

Field Summary
static int DEFAULT_PURSE
          The default purse amount.
 
Constructor Summary
Player()
          Constructs a new Player with the default name and purse amount.
Player(java.lang.String name)
          Constructs a new Player with the given name and the default purse amount.
Player(java.lang.String name, int purse)
          Constructs a new Player with the given name and purse amount.
 
Method Summary
 java.lang.String getName()
          Gets this Player's name.
 int getPurse()
           
 void transferMoneyFrom(Player loser, int amount)
          Transfers money from the losing Player to this Player.
Precondition: 0 < amount < loser.getPurse()
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PURSE

public static final int DEFAULT_PURSE
The default purse amount. This must be 100 in your program.

See Also:
Constant Field Values
Constructor Detail

Player

public Player()
Constructs a new Player with the default name and purse amount.


Player

public Player(java.lang.String name)
Constructs a new Player with the given name and the default purse amount.

Parameters:
name - the name of this Player

Player

public Player(java.lang.String name,
              int purse)
Constructs a new Player with the given name and purse amount.

Parameters:
name - the name of this Player
purse - the amount of money in this Player's purse
Method Detail

getPurse

public int getPurse()
Returns:
Returns the player's current purse amount.

transferMoneyFrom

public void transferMoneyFrom(Player loser,
                              int amount)
Transfers money from the losing Player to this Player.
Precondition: 0 < amount < loser.getPurse()

Parameters:
loser - the Player losing the bet
amount - the amount of money to transfer from the loser to this Player.

getName

public java.lang.String getName()
Gets this Player's name.

Returns:
Returns the name.