org.intranet.elevator.model.operate.controller
Class SimpleController

java.lang.Object
  extended byorg.intranet.elevator.model.operate.controller.SimpleController
All Implemented Interfaces:
Controller

public class SimpleController
extends java.lang.Object
implements Controller

Goal 1: (Complete) Elevators should stop when there are no car requests and no floor requests. Goal 2: (Incomplete) Optimization - skip unnecessary floors If a button has been pressed, the elevator goes to that floor. If there is a person in the car, then we travel to the appropriate floor.


Field Summary
private  java.util.List cars
           
private  boolean carsMoving
           
private  boolean up
           
 
Constructor Summary
SimpleController()
           
 
Method Summary
 void addCar(Car car, float stoppingDistance)
           
 boolean arrive(Car car)
          To be called only once when a car arrives at a location.
private  void evaluateCarsMoving(Car car)
           
private  int getCurrentIndex(Car car)
           
 void initialize(EventQueue eQ)
           
private  void moveCars()
           
 void requestCar(Floor newFloor, Direction d)
           
private  void sendToNextFloor(Car car)
           
 void setNextDestination(Car car)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cars

private java.util.List cars

up

private boolean up

carsMoving

private boolean carsMoving
Constructor Detail

SimpleController

public SimpleController()
Method Detail

initialize

public void initialize(EventQueue eQ)
Specified by:
initialize in interface Controller

requestCar

public void requestCar(Floor newFloor,
                       Direction d)
Specified by:
requestCar in interface Controller

moveCars

private void moveCars()

addCar

public void addCar(Car car,
                   float stoppingDistance)
Specified by:
addCar in interface Controller

arrive

public boolean arrive(Car car)
Description copied from interface: Controller
To be called only once when a car arrives at a location. This allows the controller to update any internal data structures that were keeping track of where the car was going to.

Specified by:
arrive in interface Controller
Parameters:
car - The car that is arriving.
Returns:
Whether the car is going up after this arrival. Can be used to set the direction light on the entrance.

getCurrentIndex

private int getCurrentIndex(Car car)

sendToNextFloor

private void sendToNextFloor(Car car)

toString

public java.lang.String toString()

evaluateCarsMoving

private void evaluateCarsMoving(Car car)

setNextDestination

public void setNextDestination(Car car)
Specified by:
setNextDestination in interface Controller