assign5
Class DeliveryTruck

java.lang.Object
  extended by assign5.DeliveryTruck

public class DeliveryTruck
extends java.lang.Object


Constructor Summary
DeliveryTruck()
          Creates a new instance of DeliveryTruck.
DeliveryTruck(java.lang.String id)
          Creates a new instance of DeliveryTruck Given truck id rest takes defaults
DeliveryTruck(java.lang.String id, java.lang.String startLoc)
          Creates a new instance of DeliveryTruck Given truck id and location rest takes defaults
DeliveryTruck(java.lang.String id, java.lang.String startLoc, int holding)
          Creates a new instance of DeliveryTruck Given truck id and location and current contents of truck rest takes defaults
 
Method Summary
 boolean addBoxesDelivered(int boxes)
          Add to the truck's number of boxes delivered.
 boolean addContains(int number)
          Add to the truck contents.
 boolean addDistanceDriven(int dist)
          Add to the truck's number of units traveled.
 boolean dropoff(int boxes)
          Very controlled handling of package dropoff.
 int getBoxesDelivered()
          Report the number of boxes delivered since the start of the game / simulation
 int getContains()
          report the contents of the truck - in number of boxes
 java.lang.String getCurrLoc()
          Report the current location of the truck
 int getDistanceDriven()
          Report the number of miles driven
 double getProfit()
          report profit for the truck - based on constants defined in class and truck activity - miles driven and boxes delivered.
 java.lang.String getTruckID()
          report the unique (we hope) identifier of the truck
 void resetBoxesDelivered()
          Reset number of boxes delivered to the begining - 0
 void resetContainsd()
          Reset number of boxes on the truck to the begining - 0
 void resetDistanceDriven()
          Reset distance traveled to the begining - 0
 void setCurrLoc(java.lang.String newLoc)
          Change the truck location to a new place no validation done - all locations accepted
 void setTruckID(java.lang.String id)
          Change the truck id to a new value no validation done - all ids accepted
 boolean subtractContains(int number)
          Subtract from the truck contents.
 java.lang.String toString()
          produce a display friendly reprentation of a truck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeliveryTruck

public DeliveryTruck()
Creates a new instance of DeliveryTruck. Uses all default info


DeliveryTruck

public DeliveryTruck(java.lang.String id)
Creates a new instance of DeliveryTruck Given truck id rest takes defaults


DeliveryTruck

public DeliveryTruck(java.lang.String id,
                     java.lang.String startLoc)
Creates a new instance of DeliveryTruck Given truck id and location rest takes defaults


DeliveryTruck

public DeliveryTruck(java.lang.String id,
                     java.lang.String startLoc,
                     int holding)
Creates a new instance of DeliveryTruck Given truck id and location and current contents of truck rest takes defaults

Method Detail

getTruckID

public java.lang.String getTruckID()
report the unique (we hope) identifier of the truck


getContains

public int getContains()
report the contents of the truck - in number of boxes


getCurrLoc

public java.lang.String getCurrLoc()
Report the current location of the truck


getBoxesDelivered

public int getBoxesDelivered()
Report the number of boxes delivered since the start of the game / simulation


getDistanceDriven

public int getDistanceDriven()
Report the number of miles driven


getProfit

public double getProfit()
report profit for the truck - based on constants defined in class and truck activity - miles driven and boxes delivered. Provided for students since we probably don't have enough experience yet.


setTruckID

public void setTruckID(java.lang.String id)
Change the truck id to a new value no validation done - all ids accepted


setCurrLoc

public void setCurrLoc(java.lang.String newLoc)
Change the truck location to a new place no validation done - all locations accepted


addBoxesDelivered

public boolean addBoxesDelivered(int boxes)
Add to the truck's number of boxes delivered. More control is available through dropoff. For now, doesn't check if negative amount specified, and always returns true.


resetBoxesDelivered

public void resetBoxesDelivered()
Reset number of boxes delivered to the begining - 0


addContains

public boolean addContains(int number)
Add to the truck contents. For now, doesn't check if negative amount specified, and always returns true.


subtractContains

public boolean subtractContains(int number)
Subtract from the truck contents. Used for delivery. For now, doesn't check if negative amount specified, and always returns true.


resetContainsd

public void resetContainsd()
Reset number of boxes on the truck to the begining - 0


addDistanceDriven

public boolean addDistanceDriven(int dist)
Add to the truck's number of units traveled. For now, doesn't check if negative amount specified, and always returns true.


resetDistanceDriven

public void resetDistanceDriven()
Reset distance traveled to the begining - 0


dropoff

public boolean dropoff(int boxes)
Very controlled handling of package dropoff. Changes both the number of boxes delivered and the number on the truck. Highly recommended over independent methods. For now, doesn't check if negative amount specified, and always returns true.


toString

public java.lang.String toString()
produce a display friendly reprentation of a truck

Overrides:
toString in class java.lang.Object