|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--UPSTruckSimple.UPSTruckSimple
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 |
public UPSTruckSimple()
public UPSTruckSimple(java.lang.String id, java.lang.String startLoc)
public UPSTruckSimple(java.lang.String id, java.lang.String startLoc, int holds)
Method Detail |
public java.lang.String getTruckID()
public int getCapacity()
public int getContains()
public java.lang.String getCurrLoc()
public int getBoxesDelivered()
public boolean isFull()
public void setTruckID(java.lang.String id)
public void setCurrLoc(java.lang.String newLoc)
public boolean pickup(int numItems)
public boolean pickup(int numItems, java.lang.String where)
public boolean dropoff(int numItems)
public boolean dropoff(int numItems, java.lang.String where)
public boolean driveTo(java.lang.String where)
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
args
- the command line arguments
A simple test driver
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |