Class Depot

java.lang.Object
  extended by Depot

public class Depot
extends java.lang.Object


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

priceFactor

private double priceFactor
The price factor for the Depot. This value will always be 1.0 or greater.


myLocation

private Location myLocation
The Location associated with the Depot. Default is null.


name

private java.lang.String name
The name of the Depot. Default is ""


myInventory

private Inventory myInventory
The Inventory of the Depot.

Constructor Detail

Depot

public Depot(Location loc)
Specific one-parameter constructor. Initializes the Depot's myLocation to loc, generates a random Depot name, and creates a new Inventory with the default game values specified in the Game constants.

Parameters:
loc - The Location to associate with the Depot

Depot

public Depot(double factor,
             Location loc,
             java.lang.String n)
Specific three-parameter constructor

Parameters:
factor - The price factor for the Depot
loc - The Location to associate with the Depot
n - The name of the Depot
Method Detail

getLocation

public Location getLocation()
Returns:
Returns the location.

setLocation

public void setLocation(Location theLocation)
Parameters:
theLocation - The location to set.

getPriceFactor

public double getPriceFactor()
Returns:
Returns the priceFactor.

setPriceFactor

public void setPriceFactor(double thePriceFactor)
Sets the price factor if it is valid. Valid price factor values are 1.0 or greater.

Parameters:
thePriceFactor - The priceFactor to set.

getName

public java.lang.String getName()
Returns:
Returns the name.

setName

public void setName(java.lang.String theName)
Parameters:
theName - The name to set.

getInventory

public Inventory getInventory()
Returns:
Returns myInventory

setInventory

public void setInventory(Inventory theInventory)
Parameters:
theInventory - The inventory to set the private Inventory property to.

printDepotCommands

public void printDepotCommands()
Prints the commands available in the Depot. Valid commands are: buy (but items) sell (sell items) available (show what is available in the Depot) inventory (show the Party's inventory) exit (exit the Depot)


enterDepot

public void enterDepot(Vehicle player)
Handles transactions that are possible in the Depot. (See 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

Parameters:
player - The Vehicle that will enter the Depot

buyItem

public 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.

Parameters:
theVehicle - The vehicle (player) buying the item

sellItem

public 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. This method uses 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.

Parameters:
theVehicle - The vehicle (player) selling the item