|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--Crane
A crane used in a warehouse to store and remove parcels from a grid of possible locations using row and column coordinates. A crane can hold an arbitrary number of parcels, whether performing an add or remove operation.
Field Summary | |
protected static int |
delay
Delay time for all cranes. |
protected Point |
destination
Current move destination in warehouse. |
static String |
DESTINATION
Bound property name for the destination property. |
protected ACraneStrategy |
driver
Device driver governing the operation of this crane. |
protected SwingPropertyChangeSupport |
listeners
Helper object for property change support. |
protected Point |
location
Current location in warehouse. |
static String |
LOCATION
Bound property name for the location property. |
protected Statistics |
stats
Current operating statistics for this crane. |
protected String |
status
Status description for this crane. |
static String |
STATUS
Bound property name for the status property. |
protected boolean |
stopNow
Whether or not this crane should stop operation. |
static String |
STRATEGY
Bound property name for the strategy property. |
protected Warehouse |
warehouse
Warehouse on which this crane operates. |
Constructor Summary | |
Crane(Warehouse w)
Constructs a crane operating on the given warehouse. |
Method Summary | |
Parcel |
add(Parcel p)
Sets the parcel at the current crane location to the given parcel. |
boolean |
addOrder(Order anOrder)
Places the given order in the warehouse and returns true ,
or returns false if it could not be placed. |
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds the given property change listener to the list of property change listeners for this crane. |
boolean |
contains(Parcel p)
Returns true if the current crane location
contains the given parcel, or false
if it does not contain the given parcel. |
protected void |
delay()
Delays operation of this crane. |
static int |
distance(Point p,
Point q)
Returns the number of steps required for a crane to move from the first given point to the second given point. |
int |
getColumn()
Returns the column index of the location of this crane. |
Point |
getDestination()
Returns the destination of this crane, or null if it has no current destination. |
Point |
getLocation()
Returns the location of this crane. |
protected Parcel |
getParcel()
Returns the parcel at the current crane location. |
int |
getRow()
Returns the row index of the location of this crane. |
Statistics |
getStatistics()
Returns the current operating statistics for this crane. |
String |
getStatus()
Returns the status description for this crane. |
ACraneStrategy |
getStrategy()
Returns the strategy for this crane. |
void |
installStrategy(ACraneStrategy d)
Installs the given device driver into this crane. |
boolean |
isEmpty()
Returns whether or not the current crane location is an empty warehouse location. |
protected void |
moved()
Called every time this crane moves. |
protected void |
moveDown()
Moves this crane one row to the south. |
protected void |
moveLeft()
Moves this crane one column to the left. |
protected void |
moveRight()
Moves this crane one column to the right. |
void |
moveTo(int row,
int col)
Moves this crane to the given warehouse location. |
protected void |
moveUp()
Moves this crane one row to the north. |
void |
quit()
Stops the operation of this crane. |
Parcel |
remove()
Removes and returns the parcel at the current crane location. |
boolean |
removeOrder(Order anOrder)
Removes the given order from the warehouse and returns true ,
or returns false if it could not be removed. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Adds the given property change listener to the list of property change listeners for this crane. |
void |
reset()
Resets this crane. |
static void |
setDelay(int delayTime)
Sets the delay time for all warehouse cranes to the given number of milliseconds. |
protected void |
setDestination(Point p)
Sets the destination for this crane to the given destination. |
protected Parcel |
setParcel(Parcel p)
Sets the parcel at the current crane location to the given parcel. |
protected void |
setStatus(String description)
Sets the status description for this crane to the given description. |
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 |
public static final String STRATEGY
public static final String LOCATION
public static final String DESTINATION
public static final String STATUS
protected static int delay
protected Warehouse warehouse
protected ACraneStrategy driver
protected Statistics stats
protected String status
protected Point location
protected Point destination
protected boolean stopNow
protected SwingPropertyChangeSupport listeners
Constructor Detail |
public Crane(Warehouse w)
w
- the warehouse on which this crane is to operateMethod Detail |
public void addPropertyChangeListener(PropertyChangeListener l)
l
- the listener to be addedpublic void removePropertyChangeListener(PropertyChangeListener l)
l
- the listener to be addedpublic 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 void installStrategy(ACraneStrategy d)
d
- the device driver for this cranepublic ACraneStrategy getStrategy()
public void quit()
public Statistics getStatistics()
public String getStatus()
public Point getLocation()
public int getRow()
public int getColumn()
public Point getDestination()
null
if it has no current destination.
public void moveTo(int row, int col)
row
- the row number of the locationcol
- the column number of the locationpublic boolean isEmpty()
public boolean contains(Parcel p)
true
if the current crane location
contains the given parcel, or false
if it does not contain the given parcel.
p
- the parcel for the querypublic Parcel add(Parcel p)
p
- the parcel to place in the spacepublic Parcel remove()
protected void setStatus(String description)
description
- a description of the status of this craneprotected Parcel getParcel()
protected Parcel setParcel(Parcel p)
p
- the parcel to place at the current location
null
if the space is emptyprotected void setDestination(Point p)
p
- the destination space for this craneprotected void moved()
protected void moveLeft()
protected void moveRight()
protected void moveUp()
protected void moveDown()
protected void delay()
public static void setDelay(int delayTime)
delayTime
- the delay time in millisecondspublic static int distance(Point p, Point q)
p
- the first pointq
- the second point
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |