UPSTruckSimple
Class UPSTruckSimple

java.lang.Object
  |
  +--UPSTruckSimple.UPSTruckSimple

public class UPSTruckSimple
extends java.lang.Object


Constructor Summary
UPSTruckSimple()
          Creates a new instance of UPSTruck Uses all default info
UPSTruckSimple(java.lang.String id, java.lang.String startLoc)
          Creates a new instance of UPSTruck Given truck id and location rest takes defaults
UPSTruckSimple(java.lang.String id, java.lang.String startLoc, int holds)
          Creates a new instance of UPSTruck Given truck id and location and capacity of truck rest takes defaults
 
Method Summary
 boolean driveTo(java.lang.String where)
          go to given location
 boolean dropoff(int numItems)
          drop off a number of boxes in the current location returns false if hit empty before dropping all off
 boolean dropoff(int numItems, java.lang.String where)
          drop off a number of boxes in the given location returns false if try to drop off more than we have or if can't make it to the location
 int getBoxesDelivered()
          Report the number of boxes delivered since the start of the game / simulation
 int getCapacity()
          report the capacity of the truck - in number of boxes
 int getContains()
          report the contents of the truck - in number of boxes
 java.lang.String getCurrLoc()
          Report the current location of the truck
 java.lang.String getTruckID()
          report the unique (we hope) identifier of the truck
 boolean isFull()
          Report whether the truck is full should never get over capacity, but this method will report full if somehow it does
static void main(java.lang.String[] args)
           
 boolean pickup(int numItems)
          pickup a number of boxes in the current location returns false if hit capacity
 boolean pickup(int numItems, java.lang.String where)
          pickup a number of boxes in the given location returns false if hit capacity or if can't make it to the location
 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
 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

UPSTruckSimple

public UPSTruckSimple()
Creates a new instance of UPSTruck Uses all default info


UPSTruckSimple

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


UPSTruckSimple

public UPSTruckSimple(java.lang.String id,
                      java.lang.String startLoc,
                      int holds)
Creates a new instance of UPSTruck Given truck id and location and capacity of truck rest takes defaults

Method Detail

getTruckID

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


getCapacity

public int getCapacity()
report the capacity of the truck - in number of boxes


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


isFull

public boolean isFull()
Report whether the truck is full should never get over capacity, but this method will report full if somehow it does


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


pickup

public boolean pickup(int numItems)
pickup a number of boxes in the current location returns false if hit capacity


pickup

public boolean pickup(int numItems,
                      java.lang.String where)
pickup a number of boxes in the given location returns false if hit capacity or if can't make it to the location


dropoff

public boolean dropoff(int numItems)
drop off a number of boxes in the current location returns false if hit empty before dropping all off


dropoff

public boolean dropoff(int numItems,
                       java.lang.String where)
drop off a number of boxes in the given location returns false if try to drop off more than we have or if can't make it to the location


driveTo

public boolean driveTo(java.lang.String where)
go to given location


toString

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

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments A simple test driver