rails.game
Class Player

java.lang.Object
  extended by rails.game.Player
All Implemented Interfaces:
java.lang.Comparable<Player>, CashHolder

public class Player
extends java.lang.Object
implements CashHolder, java.lang.Comparable<Player>

Player class holds all player-specific data


Field Summary
static int MAX_PLAYERS
           
static int MIN_PLAYERS
           
 
Constructor Summary
Player(java.lang.String name, int index)
           
 
Method Summary
 void addCash(int amount)
          Add (or subtract) cash.
 boolean blockCash(int amount)
          Block cash allocated by a bid.
 int compareTo(Player p)
          Compare Players by their total worth, in descending order.
 int getBlockedCash()
           
 MoneyModel getBlockedCashModel()
           
 int getCash()
          Returns the amount of cash.
 ModelObject getCashModel()
           
 CertCountModel getCertCountModel()
           
 int getFreeCash()
          Return the unblocked cash (available for bidding)
 CalculatedMoneyModel getFreeCashModel()
           
 int getIndex()
           
 MoneyModel getLastORWorthIncrease()
           
 java.lang.String getName()
          Get the cash owner's name (needed for logging)
 java.lang.String getNameAndPriority()
           
 Portfolio getPortfolio()
           
 int getWorth()
          Get the player's total worth.
 CalculatedMoneyModel getWorthModel()
           
 boolean hasBoughtStockThisTurn()
           
 boolean isBankrupt()
           
 void setBankrupt()
           
 void setIndex(int index)
           
 void setLastORWorthIncrease()
           
 void setWorthAtORStart()
           
 java.lang.String toString()
           
 boolean unblockCash(int amount)
          Unblock cash.
 void updateWorth()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_PLAYERS

public static int MAX_PLAYERS

MIN_PLAYERS

public static int MIN_PLAYERS
Constructor Detail

Player

public Player(java.lang.String name,
              int index)
Method Detail

getPortfolio

public Portfolio getPortfolio()
Returns:
Returns the player's portfolio.

getName

public java.lang.String getName()
Description copied from interface: CashHolder
Get the cash owner's name (needed for logging)

Specified by:
getName in interface CashHolder
Returns:
Returns the player's name.

getNameAndPriority

public java.lang.String getNameAndPriority()

getCash

public int getCash()
Description copied from interface: CashHolder
Returns the amount of cash.

Specified by:
getCash in interface CashHolder
Returns:
Returns the player's wallet.

getCashModel

public ModelObject getCashModel()
Specified by:
getCashModel in interface CashHolder

addCash

public void addCash(int amount)
Description copied from interface: CashHolder
Add (or subtract) cash.

Specified by:
addCash in interface CashHolder

getWorth

public int getWorth()
Get the player's total worth.

Returns:
Total worth

getWorthModel

public CalculatedMoneyModel getWorthModel()

getLastORWorthIncrease

public MoneyModel getLastORWorthIncrease()

setWorthAtORStart

public void setWorthAtORStart()

setLastORWorthIncrease

public void setLastORWorthIncrease()

updateWorth

public void updateWorth()

getCertCountModel

public CertCountModel getCertCountModel()

getFreeCashModel

public CalculatedMoneyModel getFreeCashModel()

getBlockedCashModel

public MoneyModel getBlockedCashModel()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hasBoughtStockThisTurn

public boolean hasBoughtStockThisTurn()
Returns:
Returns the hasBoughtStockThisTurn.

blockCash

public boolean blockCash(int amount)
Block cash allocated by a bid.

Parameters:
amount - Amount of cash to be blocked.
Returns:
false if the amount was not available.

unblockCash

public boolean unblockCash(int amount)
Unblock cash.

Parameters:
amount - Amount to be unblocked.
Returns:
false if the given amount was not blocked.

getFreeCash

public int getFreeCash()
Return the unblocked cash (available for bidding)

Returns:

getBlockedCash

public int getBlockedCash()

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

setBankrupt

public void setBankrupt()

isBankrupt

public boolean isBankrupt()

compareTo

public int compareTo(Player p)
Compare Players by their total worth, in descending order. This method implements the Comparable interface. second level decision is by name

Specified by:
compareTo in interface java.lang.Comparable<Player>