public class Player
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
INITIAL_MONEY |
| Constructor and Description |
|---|
Player(java.lang.String name)
Constructs a new Player.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMoney(int amount)
Add to the Player's cash balance
|
int |
getLocation()
Gets the current location of the Player.
|
int |
getMoney()
Gets the current cash balance of the Player
|
java.lang.String |
getName()
Gets the name of the Player.
|
int |
getNetWorth()
Computes the net worth of the player.
|
boolean |
ownsProperty(Property property)
Checks if the Player owns a Property
|
void |
purchaseProperty(Property property)
Purchase a Property.
|
void |
setLocation(int location)
Sets the current location of the Player
|
void |
subtractMoney(int amount)
Subtract from the Player's cash balance
|
java.lang.String |
toString()
Create a String representation of this Player.
|
private static final int INITIAL_MONEY
public Player(java.lang.String name)
Default values: players should start at space 0 on the board, have a cash balance of INITIAL_MONEY, and own no properties.
name - The name of the playerpublic java.lang.String toString()
String should be as follows:
"player-name"
E.g.:
Alice
toString in class java.lang.Objectpublic java.lang.String getName()
public int getLocation()
public void setLocation(int location)
location - The space number to which the Player is movingpublic int getMoney()
public void addMoney(int amount)
amount - The dollar amount to addpublic void subtractMoney(int amount)
amount - The dollar amount to subtractpublic boolean ownsProperty(Property property)
property - The Property to checkpublic void purchaseProperty(Property property)
Player's cash balance is decremented by the cost of the Property.
Record that this Player is now the owner of the Property.
property - The Property to purchasepublic int getNetWorth()
Net worth is calculated as the sum of the player's current money, plus the cost of each of their properties, plus the cost of each house they own.