rails.game
Class Bank

java.lang.Object
  extended by rails.game.Bank
All Implemented Interfaces:
CashHolder, ConfigurableComponentI

public class Bank
extends java.lang.Object
implements CashHolder, ConfigurableComponentI


Field Summary
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
Bank()
           
 
Method Summary
 void addCash(int amount)
          Adds cash back to the bank
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
 void finishConfiguration(GameManagerI gameManager)
          This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first.
static java.lang.String format(int amount)
           
static java.lang.String formatIntegerArray(int[] amountList)
           
 int getCash()
          Returns the amount of cash.
 ModelObject getCashModel()
           
 java.lang.String getFormattedCash()
           
 Portfolio getIpo()
           
 java.lang.String getName()
          Get the cash owner's name (needed for logging)
 Portfolio getPool()
           
 Portfolio getScrapHeap()
           
 Portfolio getUnavailable()
           
 void setCash(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log
Constructor Detail

Bank

public Bank()
Method Detail

configureFromXML

public void configureFromXML(Tag tag)
                      throws ConfigurationException
Description copied from interface: ConfigurableComponentI
Instructs the component to configure itself from the provided XML element.

Specified by:
configureFromXML in interface ConfigurableComponentI
Throws:
ConfigurationException
See Also:
rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element)

finishConfiguration

public void finishConfiguration(GameManagerI gameManager)
Description copied from interface: ConfigurableComponentI
This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first. This includes creating any required relationships to other configured components and objects.

This method should be called where necessary after all XML file parsing has completed, so that all objects that need to be related to do exist.

Specified by:
finishConfiguration in interface ConfigurableComponentI
Parameters:
gameManager - The 'parent' configurable component is passed to allow the 'child' to access any other object without the need to resort to static calls where possible.

getIpo

public Portfolio getIpo()
Returns:
IPO Portfolio

getScrapHeap

public Portfolio getScrapHeap()

getCash

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

Specified by:
getCash in interface CashHolder
Returns:
Bank's current cash level

addCash

public void addCash(int amount)
Adds cash back to the bank

Specified by:
addCash in interface CashHolder

getPool

public Portfolio getPool()
Returns:
Portfolio of stock in Bank Pool

getUnavailable

public Portfolio getUnavailable()
Returns:
Portfolio of unavailable shares

setCash

public void setCash(int i)
Parameters:
Set - Bank's cash.

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

getFormattedCash

public java.lang.String getFormattedCash()

getCashModel

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

format

public static java.lang.String format(int amount)

formatIntegerArray

public static java.lang.String formatIntegerArray(int[] amountList)