|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Depot
public class Depot
Field Summary | |
---|---|
private Inventory |
myInventory
The Inventory of the Depot. |
private Location |
myLocation
The Location associated with the Depot. |
private java.lang.String |
name
The name of the Depot. |
private double |
priceFactor
The price factor for the Depot. |
Constructor Summary | |
---|---|
Depot(double factor,
Location loc,
java.lang.String n)
Specific three-parameter constructor |
|
Depot(Location loc)
Specific one-parameter constructor. |
Method Summary | |
---|---|
void |
buyItem(Vehicle theVehicle)
Finds the item the vehicle(player) wants to buy in the depot's inventory, by calling Parser.getItemToTrade(Inventory, double) , then checks
if the player has enough money to buy the item, if so removes it from
the market's inventory, adds it to the vehicle's inventory and subtracts
the cost from the vehicle's (player's) money. |
void |
enterDepot(Vehicle player)
Handles transactions that are possible in the Depot. |
Inventory |
getInventory()
|
Location |
getLocation()
|
java.lang.String |
getName()
|
double |
getPriceFactor()
|
void |
printDepotCommands()
Prints the commands available in the Depot. |
void |
sellItem(Vehicle theVehicle)
Finds the item the vehicle(player) wants to sell in its inventory, removes it from the vehicle's inventory, adds it to the depot's inventory and adds the cost to the vechicle's (player's) money. |
void |
setInventory(Inventory theInventory)
|
void |
setLocation(Location theLocation)
|
void |
setName(java.lang.String theName)
|
void |
setPriceFactor(double thePriceFactor)
Sets the price factor if it is valid. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private double priceFactor
private Location myLocation
private java.lang.String name
private Inventory myInventory
Constructor Detail |
---|
public Depot(Location loc)
Game
constants.
loc
- The Location to associate with the Depotpublic Depot(double factor, Location loc, java.lang.String n)
factor
- The price factor for the Depotloc
- The Location to associate with the Depotn
- The name of the DepotMethod Detail |
---|
public Location getLocation()
public void setLocation(Location theLocation)
theLocation
- The location to set.public double getPriceFactor()
public void setPriceFactor(double thePriceFactor)
thePriceFactor
- The priceFactor to set.public java.lang.String getName()
public void setName(java.lang.String theName)
theName
- The name to set.public Inventory getInventory()
public void setInventory(Inventory theInventory)
theInventory
- The inventory to set the private Inventory property to.public void printDepotCommands()
public void enterDepot(Vehicle player)
printDepotCommands()
.)
This method will use input received from the method
to determine
what action to perform.
If the player requests
1) BUY, then buyItem() is called
2) SELL, then sellItem() is called
3) view their inventory, then printInventory() is called on the Party's inventory
4) view the Depot's inventory, then printInventory is called on the Depot's inventory
5) EXIT, then the program leaves the method.
6) An error message should be printed if an invalid option is chosen
player
- The Vehicle that will enter the Depotpublic void buyItem(Vehicle theVehicle)
Parser.getItemToTrade(Inventory, double)
, then checks
if the player has enough money to buy the item, if so removes it from
the market's inventory, adds it to the vehicle's inventory and subtracts
the cost from the vehicle's (player's) money.
theVehicle
- The vehicle (player) buying the itempublic void sellItem(Vehicle theVehicle)
Parser.getItemToTrade(Inventory, double)
to prompt the player for an
item they wish to sell.
Once the player selects the item, they must sell all of their stock of that item.
theVehicle
- The vehicle (player) selling the item
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |