models
Class EmergencyController

java.lang.Object
  extended by models.EmergencyController
All Implemented Interfaces:
ControllerForElevator

public class EmergencyController
extends java.lang.Object
implements ControllerForElevator

The behaviour of an elevator when there is an emergency to be managed:
the elevator must always stay at the current floor and stop at the next floor if already moving.
Tested by JUnit_EmergencyController

Version:
1
Author:
J Paul Gibson

Constructor Summary
EmergencyController()
           
 
Method Summary
 void bindToElevator(ElevatorForController elevator)
          In this emergency controller we do not need to read the state of the elevator and so we do not need to bind the 2 components together.
 Direction calculateDirection()
          In an emergency situation the controller must always stay at the current floor
Tested by JUnit_EmergencyController.test_calculateDirection()
 boolean stopAtNextFloor()
          In an emergency situation the controller must stop at the next floor
Tested by JUnit_EmergencyController.test_stopAtNextFloor()
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EmergencyController

public EmergencyController()
Method Detail

bindToElevator

public void bindToElevator(ElevatorForController elevator)
                    throws java.lang.IllegalArgumentException
In this emergency controller we do not need to read the state of the elevator and so we do not need to bind the 2 components together. We keep the empty method to make the emergency behaviour easy to change or update.

Specified by:
bindToElevator in interface ControllerForElevator
Parameters:
elevator - is the unique elevator to which the controller is now connected
Throws:
java.lang.IllegalArgumentException - if the elevator being connected is null

calculateDirection

public Direction calculateDirection()
In an emergency situation the controller must always stay at the current floor
Tested by JUnit_EmergencyController.test_calculateDirection()

Specified by:
calculateDirection in interface ControllerForElevator
Returns:
the direction in which the lift should next move

stopAtNextFloor

public boolean stopAtNextFloor()
In an emergency situation the controller must stop at the next floor
Tested by JUnit_EmergencyController.test_stopAtNextFloor()

Specified by:
stopAtNextFloor in interface ControllerForElevator
Returns:
whether the lift should stop at the next floor after it has completed its move

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object