|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Vehicle
public class Vehicle
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 |
---|
private java.lang.String vehicleType
private double fuel
private java.lang.String fuelUnits
private double fuelBurnRate
private double money
private Inventory inventory
private Location location
private double totalDistanceTraveled
Constructor Detail |
---|
public Vehicle()
public Vehicle(java.lang.String theVehicleType, Location theLocation, Inventory theInventory, double theFuel, java.lang.String theFuelUnits, double theFuelBurnRate, double theMoney, double theTotalDistanceTraveled)
theLocation
- The location in the universe where the player is currentlytheInventory
- The vehicle's inventorytheFuel
- The amount of fuel for the vehicletheMoney
- The amount of money for the vehicle (player)theFuelUnits
- The units of fuel (gallons, liters, etc.)theFuelBurnRate
- How much fuel this vehicle burns when travelingtheTotalDistanceTraveled
- How far this vehicle has traveled so fartheVehicleType
- The name of the vehicleMethod Detail |
---|
public java.lang.String getVehicleType()
public void setVehicleType(java.lang.String newVehicleType)
newVehicleType
- The new VehicleType value.public double getFuel()
public void setFuel(double newFuel)
newFuel
- The new Fuel value.public java.lang.String getFuelUnits()
public void setFuelUnits(java.lang.String newFuelUnits)
newFuelUnits
- The new FuelUnits value.public double getFuelBurnRate()
public void setFuelBurnRate(double newFuelBurnRate)
newFuelBurnRate
- The new FuelBurnRate value.public double getMoney()
public void setMoney(double newMoney)
newMoney
- The new Money value.public Inventory getInventory()
public void setInventory(Inventory newInventory)
newInventory
- The new Inventory value.public Location getLocation()
public void setLocation(Location newLocation)
newLocation
- The new Location value.public double getTotalDistanceTraveled()
public void setTotalDistanceTraveled(double newTotalDistanceTraveled)
newTotalDistanceTraveled
- The new TotalDistanceTraveled value.public void addToMoney(double amount)
amount
- The amount of money to add to the vehicle's current amountpublic void subtractFromMoney(double amount)
amount
- The amount of money to subtract from the vehicle's current amountpublic void travelToLocation(Location location)
location
- The location to travel topublic void printLocationCommands()
public void takeTurn()
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
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |