org.intranet.elevator.model
Class MovableLocation

java.lang.Object
  extended byorg.intranet.sim.ModelElement
      extended byorg.intranet.elevator.model.Location
          extended byorg.intranet.elevator.model.MovableLocation
Direct Known Subclasses:
Car

public abstract class MovableLocation
extends Location

A location that can move. The state of movement is kept between height and destinationHeight. If they are equal, then the MovableLocation is still. If they are not equal, then the MovableLocation is moving. Valid states:

State Variables Transitions
destinationHeight setDestinationHeight() [ArrivalEvent]
IDLE height IDLE:[arrive()] or travel(): MOVING Impossible
MOVING other IDLE:[arrive()] or travel(): MOVING IDLE:[arrive()]

Note that arrive() is like an event that is picked up by the subclass, as it is an abstract method.


Nested Class Summary
private  class MovableLocation.ArrivalEvent
           
 
Field Summary
private  Event arrivalEvent
           
private  float destinationHeight
           
private  int numTravels
           
private  float totalDistance
           
 
Fields inherited from class org.intranet.elevator.model.Location
 
Fields inherited from class org.intranet.sim.ModelElement
eventQueue
 
Constructor Summary
(package private) MovableLocation(EventQueue eQ, float height, int capacity)
           
 
Method Summary
protected abstract  void arrive()
           
private  void checkDirectionChange(float h)
           
 int getNumTravels()
           
protected abstract  float getRatePerSecond()
           
 float getTotalDistance()
           
 float getTravelTime(float distance)
           
protected  void setDestinationHeight(float h)
           
 void setHeight(float newHeight)
           
private  void travel()
           
 
Methods inherited from class org.intranet.elevator.model.Location
getCapacity, getHeight, getPeople, isAtCapacity, personEnters, personLeaves
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

destinationHeight

private float destinationHeight

totalDistance

private float totalDistance

numTravels

private int numTravels

arrivalEvent

private Event arrivalEvent
Constructor Detail

MovableLocation

MovableLocation(EventQueue eQ,
                float height,
                int capacity)
Method Detail

getTotalDistance

public final float getTotalDistance()

getNumTravels

public final int getNumTravels()

getTravelTime

public final float getTravelTime(float distance)

setHeight

public final void setHeight(float newHeight)
Overrides:
setHeight in class Location

setDestinationHeight

protected final void setDestinationHeight(float h)

arrive

protected abstract void arrive()

getRatePerSecond

protected abstract float getRatePerSecond()

checkDirectionChange

private void checkDirectionChange(float h)

travel

private void travel()