Class ACraneStrategy

java.lang.Object
  |
  +--ACraneStrategy
Direct Known Subclasses:
CenterStrategy, RandomStrategy

public abstract class ACraneStrategy
extends Object

Base class for a strategy of operating the warehouse crane.


Field Summary
protected  Crane crane
          Crane used to operate on the warehouse.
protected  Warehouse warehouse
          Warehouse on which this driver operates.
 
Constructor Summary
ACraneStrategy()
           
 
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.
protected  void beginAdd(Order anOrder)
          Called when the given order is to be added to the warehouse.
protected  void beginRemove(Order anOrder)
          Called when the given order is to be removed from the warehouse.
protected  Point getAddLocation(Parcel p)
          Returns a location in the warehouse at which the given parcel should be added.
abstract  String getName()
          Returns the name of this device driver.
protected  Point getRemoveLocation(Order anOrder)
          Returns a location in the warehouse from which a parcel in the given order should be removed.
 void installInto(Crane aCrane, Warehouse aWarehouse)
          Installs this device driver into the given crane operating in the given warehouse.
protected  int orderNumberAt(int aRow, int aColumn)
          Returns the order number for the parcel stored at the given row and colum coordinates, or -1 if the coordinates represent an empty space.
protected  void parcelAdded(int aRow, int aColumn, Parcel aParcel)
          Called when the given parcel has successfully been added to the warehouse at the given location.
protected  void parcelPlacedAt(int aRow, int aColumn, int anOrder)
          Stores the fact that the given row and column coordinates contain a parcel with the given order number.
protected  void parcelRemoved(int aRow, int aColumn, Parcel aParcel)
          Called when the given parcel has successfully been removed from the warehouse from the given location.
protected  void parcelRemovedFrom(int aRow, int aColumn)
          Stores the fact that the given row and column coordinates no longer contain a parcel.
 void quit()
          Causes this device driver to quit operation.
 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()
          Resets this device driver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

warehouse

protected Warehouse warehouse
Warehouse on which this driver operates.


crane

protected Crane crane
Crane used to operate on the warehouse.

Constructor Detail

ACraneStrategy

public ACraneStrategy()
Method Detail

installInto

public void installInto(Crane aCrane,
                        Warehouse aWarehouse)
Installs this device driver into the given crane operating in the given warehouse.

Parameters:
aCrane - crane to be operated by this driver
aWarehouse - warehouse in which the given crane operates

reset

public void reset()
Resets this device driver.


quit

public void quit()
Causes this device driver to quit operation.


addOrder

public boolean addOrder(Order anOrder)
Places the given order in the warehouse and returns true, or returns false if it could not be placed.

Parameters:
anOrder - order to place

removeOrder

public boolean removeOrder(Order anOrder)
Removes the given order from the warehouse and returns true, or returns false if it could not be removed.

Parameters:
anOrder - order to remove

parcelPlacedAt

protected void parcelPlacedAt(int aRow,
                              int aColumn,
                              int anOrder)
Stores the fact that the given row and column coordinates contain a parcel with the given order number.

Parameters:
aRow - row in warehouse
aColumn - column in warehouse
anOrder - order number

parcelRemovedFrom

protected void parcelRemovedFrom(int aRow,
                                 int aColumn)
Stores the fact that the given row and column coordinates no longer contain a parcel.

Parameters:
aRow - row in warehouse
aColumn - column in warehouse

orderNumberAt

protected int orderNumberAt(int aRow,
                            int aColumn)
Returns the order number for the parcel stored at the given row and colum coordinates, or -1 if the coordinates represent an empty space.

Parameters:
aRow - row in warehouse
aColumn - column in warehouse

beginAdd

protected void beginAdd(Order anOrder)
Called when the given order is to be added to the warehouse. The work of the algorithm should not be done here. Instead, this method should be used to preprocess data stored pertaining to the warehouse contents. The default implementation does nothing.

Parameters:
anOrder - order to be added

beginRemove

protected void beginRemove(Order anOrder)
Called when the given order is to be removed from the warehouse. The work of the algorithm should not be done here. Instead, this method should be used to preprocess data stored pertaining to the warehouse contents. The default implementation does nothing.

Parameters:
anOrder - order to be removed

getAddLocation

protected Point getAddLocation(Parcel p)
Returns a location in the warehouse at which the given parcel should be added.

Parameters:
p - the parcel to be added

getRemoveLocation

protected Point getRemoveLocation(Order anOrder)
Returns a location in the warehouse from which a parcel in the given order should be removed.

Parameters:
anOrder -

parcelAdded

protected void parcelAdded(int aRow,
                           int aColumn,
                           Parcel aParcel)
Called when the given parcel has successfully been added to the warehouse at the given location.

Parameters:
aRow - row in warehouse
aColumn - column in warehouse
aParcel - parcel that was added

parcelRemoved

protected void parcelRemoved(int aRow,
                             int aColumn,
                             Parcel aParcel)
Called when the given parcel has successfully been removed from the warehouse from the given location.

Parameters:
aRow - row in warehouse
aColumn - column in warehouse
aParcel - parcel that was removed

getName

public abstract String getName()
Returns the name of this device driver.