Class Vehicle

java.lang.Object
  extended by Vehicle

public class Vehicle
extends java.lang.Object

This class represents a Vehicle (player) within our game.


Field Summary
private  double fuel
          The amount of fuel the Vehicle has
private  double fuelBurnRate
          How fast this Vehicle burns fuel
private  java.lang.String fuelUnits
          The units of fuel -- 'gallons', 'liters', etc.
private  Inventory inventory
          The Vehicle's inventory
private  Location location
          The Vehicle's current location
private  double money
          How much money the Vehicle (i.e.
private  double totalDistanceTraveled
          The Vehicle's odometer -- how far it has traveled
private  java.lang.String vehicleType
          The name of the vehicle: 'golfcart', 'Serenity', etc.
 
Constructor Summary
Vehicle()
          The default constructor, it initializes the Vehicle to some default values
Vehicle(java.lang.String theVehicleType, Location theLocation, Inventory theInventory, double theFuel, java.lang.String theFuelUnits, double theFuelBurnRate, double theMoney, double theTotalDistanceTraveled)
          The specific constructor, it initializes the eight fields of this object.
 
Method Summary
 void addToMoney(double amount)
          Increases the vehcile's (player's) money by the amount passed
 double getFuel()
          Get the Fuel value.
 double getFuelBurnRate()
          Get the FuelBurnRate value.
 java.lang.String getFuelUnits()
          Get the FuelUnits value.
 Inventory getInventory()
          Get the Inventory value.
 Location getLocation()
          Get the Location value.
 double getMoney()
          Get the Money value.
 double getTotalDistanceTraveled()
          Get the TotalDistanceTraveled value.
 java.lang.String getVehicleType()
          Get the VehicleType value.
 void printLocationCommands()
          Prints the commands available for the location to the screen
 void setFuel(double newFuel)
          Set the Fuel value.
 void setFuelBurnRate(double newFuelBurnRate)
          Set the FuelBurnRate value.
 void setFuelUnits(java.lang.String newFuelUnits)
          Set the FuelUnits value.
 void setInventory(Inventory newInventory)
          Set the Inventory value.
 void setLocation(Location newLocation)
          Set the Location value.
 void setMoney(double newMoney)
          Set the Money value.
 void setTotalDistanceTraveled(double newTotalDistanceTraveled)
          Set the TotalDistanceTraveled value.
 void setVehicleType(java.lang.String newVehicleType)
          Set the VehicleType value.
 void subtractFromMoney(double amount)
          Decreases the vehcile's (player's) money by the amount passed
 void takeTurn()
          The is the primary method for doing an action at a location.
 void travelToLocation(Location location)
          The method to travel to the location specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vehicleType

private java.lang.String vehicleType
The name of the vehicle: 'golfcart', 'Serenity', etc.


fuel

private double fuel
The amount of fuel the Vehicle has


fuelUnits

private java.lang.String fuelUnits
The units of fuel -- 'gallons', 'liters', etc.


fuelBurnRate

private double fuelBurnRate
How fast this Vehicle burns fuel


money

private double money
How much money the Vehicle (i.e. player) has


inventory

private Inventory inventory
The Vehicle's inventory


location

private Location location
The Vehicle's current location


totalDistanceTraveled

private double totalDistanceTraveled
The Vehicle's odometer -- how far it has traveled

Constructor Detail

Vehicle

public Vehicle()
The default constructor, it initializes the Vehicle to some default values


Vehicle

public Vehicle(java.lang.String theVehicleType,
               Location theLocation,
               Inventory theInventory,
               double theFuel,
               java.lang.String theFuelUnits,
               double theFuelBurnRate,
               double theMoney,
               double theTotalDistanceTraveled)
The specific constructor, it initializes the eight fields of this object.

Parameters:
theLocation - The location in the universe where the player is currently
theInventory - The vehicle's inventory
theFuel - The amount of fuel for the vehicle
theMoney - The amount of money for the vehicle (player)
theFuelUnits - The units of fuel (gallons, liters, etc.)
theFuelBurnRate - How much fuel this vehicle burns when traveling
theTotalDistanceTraveled - How far this vehicle has traveled so far
theVehicleType - The name of the vehicle
Method Detail

getVehicleType

public java.lang.String getVehicleType()
Get the VehicleType value.

Returns:
the VehicleType value.

setVehicleType

public void setVehicleType(java.lang.String newVehicleType)
Set the VehicleType value.

Parameters:
newVehicleType - The new VehicleType value.

getFuel

public double getFuel()
Get the Fuel value.

Returns:
the Fuel value.

setFuel

public void setFuel(double newFuel)
Set the Fuel value.

Parameters:
newFuel - The new Fuel value.

getFuelUnits

public java.lang.String getFuelUnits()
Get the FuelUnits value.

Returns:
the FuelUnits value.

setFuelUnits

public void setFuelUnits(java.lang.String newFuelUnits)
Set the FuelUnits value.

Parameters:
newFuelUnits - The new FuelUnits value.

getFuelBurnRate

public double getFuelBurnRate()
Get the FuelBurnRate value.

Returns:
the FuelBurnRate value.

setFuelBurnRate

public void setFuelBurnRate(double newFuelBurnRate)
Set the FuelBurnRate value.

Parameters:
newFuelBurnRate - The new FuelBurnRate value.

getMoney

public double getMoney()
Get the Money value.

Returns:
the Money value.

setMoney

public void setMoney(double newMoney)
Set the Money value.

Parameters:
newMoney - The new Money value.

getInventory

public Inventory getInventory()
Get the Inventory value.

Returns:
the Inventory value.

setInventory

public void setInventory(Inventory newInventory)
Set the Inventory value.

Parameters:
newInventory - The new Inventory value.

getLocation

public Location getLocation()
Get the Location value.

Returns:
the Location value.

setLocation

public void setLocation(Location newLocation)
Set the Location value.

Parameters:
newLocation - The new Location value.

getTotalDistanceTraveled

public double getTotalDistanceTraveled()
Get the TotalDistanceTraveled value.

Returns:
the TotalDistanceTraveled value.

setTotalDistanceTraveled

public void setTotalDistanceTraveled(double newTotalDistanceTraveled)
Set the TotalDistanceTraveled value.

Parameters:
newTotalDistanceTraveled - The new TotalDistanceTraveled value.

addToMoney

public void addToMoney(double amount)
Increases the vehcile's (player's) money by the amount passed

Parameters:
amount - The amount of money to add to the vehicle's current amount

subtractFromMoney

public void subtractFromMoney(double amount)
Decreases the vehcile's (player's) money by the amount passed

Parameters:
amount - The amount of money to subtract from the vehicle's current amount

travelToLocation

public void travelToLocation(Location location)
The method to travel to the location specified. The cost of the fuel to travel to the new location is subtracted from the total money available and the vehicle's current location is set to the value passed, if the vehicle (player) has enough money to travel to the location sepcified.

Parameters:
location - The location to travel to

printLocationCommands

public void printLocationCommands()
Prints the commands available for the location to the screen


takeTurn

public void takeTurn()
The is the primary method for doing an action at a location. This method reads in a command from the keyboard (via Parser.parse()), then takes the appropriate action based on that command. The possible actions include traveling to another location, entering the market at the current location, printing the vehicle's inventory, printing the map of the Universe, and quiting