|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectMonopoly.Player
public class Player
This is the class Player. Invariant: Once created and until destroyed, this instance represents a valid player of the game Monopoly. Through all that time he has the same name(String) and cardinal number (int).
| Constructor Summary | |
|---|---|
Player(java.lang.String name,
int number)
Creates a new Player object for the monopoly game. |
|
| Method Summary | |
|---|---|
boolean |
buy(Property pr)
Purchase a property (Transformer). |
boolean |
buyHouse(Street st)
Purchase a house for a Street (Transformer). |
void |
collect(int value)
Receive an amount of money (Transformer). |
int |
compareTo(java.lang.Object elem)
Compares this player with the specified object for order. |
int |
getFortune()
Get this player's total fortune (property value plus cash). |
boolean |
getIsInJail()
Get the player's isInJail status (Accessor). |
GetOutOfJailCard |
getJailCard()
Get the first instance of GetOutOfJailCard that can be found in the player's properties (Accessor). |
Cell |
getLocation()
Get the player's location (Accessor). |
int |
getMoney()
Get the player's cash (Accessor). |
java.lang.String |
getName()
Get the name of the player (Accessor). |
int |
getNumber()
Get the cardinal number of the player (Accessor). |
int |
getNumOfDoubles()
Get the number of doubles this player has rolled (Accessor). |
java.util.Collection<Collectable> |
getProperties()
Get the collection of properties of that player (Accessor). |
Collectable |
getProperty(java.lang.String name)
Get the property (Collectable) of this player that matches the given String (Accessor). |
void |
mortage(Property pr)
Mortage a property (Transformer). |
void |
move(int steps,
Monopoly game)
Move the player for a number of steps (Transformer). |
void |
moveTo(Cell loc,
Monopoly game)
Move the player to a location (Transformer). |
boolean |
pay(int value)
Pay an amount of money to the Bank (Transformer). |
boolean |
pay(Player owner,
int value)
Pay an amount of money to another Player (Transformer). |
void |
releaseProperties()
Set the owner of this player's properties as null. |
void |
sell(Collectable col)
Give a Collectable object on a trade (Transformer). |
void |
sellHouse(Street st)
Sell a house of a Street (Transformer). |
void |
setIsInJail(boolean is)
Set the player's isInJail status (Transformer). |
void |
setNumOfDoubles(int value)
Set the number of doubles this player has rolled (Transformer). |
void |
setTimes(int set)
Set the number of rounds this player has been in prison (Transformer). |
int |
timesInJail()
Get the number of rounds this player has been in prison (Accessor). |
void |
trade(Collectable col)
Obtain a Collectable object from a trade (Transformer). |
boolean |
unmortage(Property pr)
Unmortage a property (Transformer). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Player(java.lang.String name,
int number)
name - the name of the playernumber - tha cardinal number of the player| Method Detail |
|---|
public java.lang.String getName()
public int getNumber()
public Cell getLocation()
public java.util.Collection<Collectable> getProperties()
public int getNumOfDoubles()
public int getMoney()
public boolean getIsInJail()
public GetOutOfJailCard getJailCard()
public Collectable getProperty(java.lang.String name)
name - the String to identify the property
getProperty(name)->null
getProperty(name).toString()->namepublic int timesInJail()
public int getFortune()
public int compareTo(java.lang.Object elem)
throws java.lang.ClassCastException
compareTo in interface java.lang.Comparableelem - the Object to be compared.
java.lang.ClassCastException - - if the specified object's type
is other than Player.public void setNumOfDoubles(int value)
value - the number of doubles
value=numOfDoubles+1 OR ZERO
public boolean buy(Property pr)
pr - the Property being purchased
pr.getOwner()->null
public void trade(Collectable col)
col - the Collectable being obtained
public void sell(Collectable col)
col - the Collectable being given
public void mortage(Property pr)
pr - the Property being mortaged
pr.getOwner()->this
pr.numOfHouses()->ZERO
pr.isMortaged()->false
public boolean unmortage(Property pr)
pr - the Property being unmortaged
pr.getOwner()->this
public boolean buyHouse(Street st)
st - the Street on which the house will be built
public void sellHouse(Street st)
st - the Street that had the house
public boolean pay(int value)
value - the amount of money to pay
public boolean pay(Player owner,
int value)
owner - the Player to payvalue - the amount of money to pay
public void collect(int value)
value - the amount of money to receive
public void setIsInJail(boolean is)
is - the status of the player
public void move(int steps,
Monopoly game)
steps - the number of steps the player will movegame - the Monopoly instance that represents the
current game and holds the board of Cells
public void moveTo(Cell loc,
Monopoly game)
loc - the Cell to which the player will move
public void setTimes(int set)
set - the number of rounds
public void releaseProperties()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||