rails.game
Class StockSpace
java.lang.Object
java.util.Observable
rails.game.model.ModelObject
rails.game.StockSpace
- All Implemented Interfaces:
- StockSpaceI
public class StockSpace
- extends ModelObject
- implements StockSpaceI
Objects of this class represent a square on the StockMarket.
| Methods inherited from class java.util.Observable |
clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
name
protected java.lang.String name
row
protected int row
column
protected int column
price
protected int price
colour
protected java.lang.String colour
belowLedge
protected boolean belowLedge
leftOfLedge
protected boolean leftOfLedge
closesCompany
protected boolean closesCompany
endsGame
protected boolean endsGame
start
protected boolean start
type
protected StockSpaceTypeI type
tokens
protected java.util.ArrayList<PublicCompanyI> tokens
fixedStartPrices
protected java.util.ArrayList<PublicCompanyI> fixedStartPrices
log
protected static org.apache.log4j.Logger log
StockSpace
public StockSpace(java.lang.String name,
int price,
StockSpaceTypeI type)
StockSpace
public StockSpace(java.lang.String name,
int price)
addToken
public boolean addToken(PublicCompanyI company)
- Add a token at the end of the array (i.e. at the bottom of the pile)
Always returns true;
- Specified by:
addToken in interface StockSpaceI
- Parameters:
company - The company object to add.
addTokenAtStackPosition
public boolean addTokenAtStackPosition(PublicCompanyI company,
int stackPosition)
- Specified by:
addTokenAtStackPosition in interface StockSpaceI
removeToken
public boolean removeToken(PublicCompanyI company)
- Remove a token from the pile.
- Specified by:
removeToken in interface StockSpaceI
- Parameters:
company - The company object to remove.
- Returns:
- False if the token was not found.
getTokens
public java.util.List<PublicCompanyI> getTokens()
- Specified by:
getTokens in interface StockSpaceI
- Returns:
getStackPosition
public int getStackPosition(PublicCompanyI company)
- Find the stack position of a company token
- Specified by:
getStackPosition in interface StockSpaceI
- Returns:
- Stock position: 0 = top, increasing towards the bottom. -1 if not
found.
addFixedStartPrice
public void addFixedStartPrice(PublicCompanyI company)
- Specified by:
addFixedStartPrice in interface StockSpaceI
getFixedStartPrices
public java.util.List<PublicCompanyI> getFixedStartPrices()
- Specified by:
getFixedStartPrices in interface StockSpaceI
isBelowLedge
public boolean isBelowLedge()
- Specified by:
isBelowLedge in interface StockSpaceI
- Returns:
- TRUE is the square is just above a ledge.
closesCompany
public boolean closesCompany()
- Specified by:
closesCompany in interface StockSpaceI
- Returns:
- TRUE if the square closes companies landing on it.
getColour
public java.awt.Color getColour()
- Specified by:
getColour in interface StockSpaceI
- Returns:
- The square's colour.
endsGame
public boolean endsGame()
- Specified by:
endsGame in interface StockSpaceI
- Returns:
- TRUE if the rails.game ends if a company lands on this square.
getPrice
public int getPrice()
- Specified by:
getPrice in interface StockSpaceI
- Returns:
- The stock price associated with the square.
getColumn
public int getColumn()
- Specified by:
getColumn in interface StockSpaceI
- Returns:
getName
public java.lang.String getName()
- Specified by:
getName in interface StockSpaceI
- Returns:
getType
public StockSpaceTypeI getType()
- Specified by:
getType in interface StockSpaceI
- Returns:
getRow
public int getRow()
- Specified by:
getRow in interface StockSpaceI
- Returns:
isStart
public boolean isStart()
- Specified by:
isStart in interface StockSpaceI
- Returns:
isLeftOfLedge
public boolean isLeftOfLedge()
- Specified by:
isLeftOfLedge in interface StockSpaceI
- Returns:
isNoBuyLimit
public boolean isNoBuyLimit()
- Specified by:
isNoBuyLimit in interface StockSpaceI
- Returns:
isNoCertLimit
public boolean isNoCertLimit()
- Specified by:
isNoCertLimit in interface StockSpaceI
- Returns:
isNoHoldLimit
public boolean isNoHoldLimit()
- Specified by:
isNoHoldLimit in interface StockSpaceI
- Returns:
setBelowLedge
public void setBelowLedge(boolean b)
- Specified by:
setBelowLedge in interface StockSpaceI
- Parameters:
b - See isAboveLedge.
setClosesCompany
public void setClosesCompany(boolean b)
- Specified by:
setClosesCompany in interface StockSpaceI
- Parameters:
b - See isClosesCompany.
setEndsGame
public void setEndsGame(boolean b)
- Specified by:
setEndsGame in interface StockSpaceI
- Parameters:
b - See isEndsGame.
setStart
public void setStart(boolean b)
- Specified by:
setStart in interface StockSpaceI
- Parameters:
set - space as a starting space
setLeftOfLedge
public void setLeftOfLedge(boolean b)
- Specified by:
setLeftOfLedge in interface StockSpaceI
- Parameters:
set - if token is left of ledge
hasTokens
public boolean hasTokens()
- Specified by:
hasTokens in interface StockSpaceI
- Returns:
- Returns if the space hasTokens.
getText
public java.lang.String getText()
- Description copied from class:
ModelObject
- The object that is sent to the Observer along with a notification. The
default result is the Observable's toString(), but it can be overridden
where needed.
- Specified by:
getText in class ModelObject
- Returns:
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object