public class Player
extends java.lang.Object
Constructor and Description |
---|
Player(java.lang.String name,
int budget,
int spycams,
GraphNode startnode)
Constructs an instance of Player to track location and other information for the player.
|
Modifier and Type | Method and Description |
---|---|
void |
decreaseBudget(int dec)
Subtract the dec amount from the budget.
|
boolean |
dropSpycam()
If there are no remaining spy cams to drop,
display "Not enough spycams" and return false.
|
int |
getBudget()
Return the amount remaining in this player's budget.
|
GraphNode |
getLocation()
Returns the node where the player is currently located.
|
java.lang.String |
getLocationName()
Returns the name (label) of the node where the player is currently located.
|
java.lang.String |
getName()
Return the name of the player.
|
void |
getSpycamBack(boolean pickupSpyCam)
If pickupSpyCam is true, increment the number of spy cams remaining.
|
int |
getSpycams()
Returns the number of spy cams available to drop.
|
boolean |
move(java.lang.String name)
Change the location of the player to the specified node.
|
boolean |
pickupSpycam(GraphNode node)
Check the node to see if there is a spy cam.
|
void |
printSpyCamLocations()
Display the names of the locations where Spy Cams were dropped (and are still there).
|
public Player(java.lang.String name, int budget, int spycams, GraphNode startnode)
name
- Player's namebudget
- Player budget to spend on movesspycams
- the number of spy cams the player starts withstartnode
- the node the player starts onpublic java.lang.String getName()
public int getBudget()
public void decreaseBudget(int dec)
dec
- The amount to decrease the budget by.public boolean dropSpycam()
If there is not a spy cam at the player's current location: display "Dropped a Spy cam at D" where D is the node name drop a spy cam (here) D decrement the remaining spy cam count if there was not already a spycam
public boolean pickupSpycam(GraphNode node)
node
- The node the player asked to remove a spy cam from.public int getSpycams()
public boolean move(java.lang.String name)
name
- Name of the neighboring to move topublic java.lang.String getLocationName()
public GraphNode getLocation()
public void getSpycamBack(boolean pickupSpyCam)
pickupSpyCam
- true if a spy cam was picked up. False means there was no spy campublic void printSpyCamLocations()
Spy cam at a Spy cam at f Spy cam at g