|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.util.Observable
|
+--Warehouse
A warehouse storing parcels in orders.
| Field Summary | |
protected Crane |
crane
Crane used to operate on this warehouse. |
protected Space[][] |
spaces
Array of spaces in this warehouse. |
| Constructor Summary | |
Warehouse(int width,
int height)
Creates a warehouse that can fit the given number of parcels per side. |
|
| Method Summary | |
boolean |
addOrder(Order anOrder)
Places the given order in the warehouse and returns true,
or returns false if it could not be placed. |
int |
getColumnCount()
Returns the number of columns in this warehouse. |
Crane |
getCrane()
Returns the crane used to operate on this warehouse. |
Parcel |
getParcel(int row,
int col)
Returns the parcel stored in this warehouse in the space at the given row and column indices. |
int |
getRowCount()
Returns the number of rows in this warehouse. |
Space[][] |
getSpaces()
Returns the array of spaces in this warehouse. |
void |
hit(Point p)
"Hits" the space at the given location. |
boolean |
isEmpty(int row,
int col)
Returns whether or not the space at the given row and column indices is empty. |
boolean |
isFragmented(Order anOrder)
Returns whether or not the given order is fragmented. |
boolean |
isFull()
Returns true if there are
no empty spaces in this warehouse,
and false if at least one empty space exists. |
boolean |
removeOrder(Order anOrder)
Removes the given order from the warehouse and returns true,
or returns false if it could not be removed. |
void |
reset()
Empties the warehouse and moves its crane to the default starting location. |
Parcel |
setParcel(int row,
int col,
Parcel p)
Sets the parcel stored in this warehouse in the space at the given row and column indices to the given parcel. |
| Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Crane crane
protected Space[][] spaces
| Constructor Detail |
public Warehouse(int width,
int height)
width - the width of the warehouse in parcelsheight - the height of the warehouse in parcels| Method Detail |
public int getRowCount()
public int getColumnCount()
public Space[][] getSpaces()
public boolean isEmpty(int row,
int col)
row - the row index of the spacecol - the column index of the space
ArrayIndexOutOfBoundsException - if the given row or column index is out of bounds
public Parcel setParcel(int row,
int col,
Parcel p)
row - the row index of the spacecol - the column index of the spacep - the parcel to be placed in the space
null if the space was empty
ArrayIndexOutOfBoundsException - if the given row or column index is out of bounds
public Parcel getParcel(int row,
int col)
row - the row index of the spacecol - the column index of the space
ArrayIndexOutOfBoundsException - if the given row or column index is out of boundspublic void hit(Point p)
public Crane getCrane()
public void reset()
public boolean addOrder(Order anOrder)
true,
or returns false if it could not be placed.
anOrder - order to placepublic boolean removeOrder(Order anOrder)
true,
or returns false if it could not be removed.
anOrder - order to removepublic boolean isFragmented(Order anOrder)
public boolean isFull()
true if there are
no empty spaces in this warehouse,
and false if at least one empty space exists.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||