models
Class Elevator

java.lang.Object
  extended by models.Elevator
All Implemented Interfaces:
ElevatorForController, ElevatorForUsers, ElevatorSpecification

public class Elevator
extends java.lang.Object
implements ElevatorSpecification


Field Summary
 int NUMBER_OF_FLOORS
           
 
Constructor Summary
Elevator(int numberOfFloors)
           
 
Method Summary
 Direction currentDirection()
           
 int currentFloor()
           
 boolean downPressedAtFloor(int floor)
          Permits elevator controller to see if a request to go down has been made at a specified floor
 boolean floorPressedInElevator(int floor)
          Permits elevator controller to see if there is a request to a particular floor
 void installController(ControllerForElevator controller)
          Update the lift controller component - intended to be done by an engineer
 boolean noMoreRequestsAbove(int floor)
           
 boolean noMoreRequestsBelow(int floor)
           
 void pressDown(int floor)
          Permits elevator users to request elevator to take them down
 void pressFloorInElevator(int floor)
          Permits elevator users inside the elevator to request elevator to take them to a particular floor
 void pressUp(int floor)
          Permits elevator users to request elevator to take them up
 int topFloor()
           
 java.lang.String toString()
           
 boolean updateFloor()
          move to next floor (as decided by the controller)
 boolean upPressedAtFloor(int floor)
          Permits elevator controller to see if a request to go up has been made at a specified floor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUMBER_OF_FLOORS

public final int NUMBER_OF_FLOORS
Constructor Detail

Elevator

public Elevator(int numberOfFloors)
         throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException
Method Detail

currentDirection

public Direction currentDirection()
Specified by:
currentDirection in interface ElevatorForController
Returns:
the current direction in which the elevator is moving

currentFloor

public int currentFloor()
Specified by:
currentFloor in interface ElevatorForController
Returns:
the current floor of the elevator

downPressedAtFloor

public boolean downPressedAtFloor(int floor)
                           throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorForController
Permits elevator controller to see if a request to go down has been made at a specified floor

Specified by:
downPressedAtFloor in interface ElevatorForController
Specified by:
downPressedAtFloor in interface ElevatorForUsers
Parameters:
floor - specifies the floor at which the request is being checked
Throws:
java.lang.IllegalArgumentException - if the floor is not valid (from 1.. NUMBER_OF_FLOORS-1)

floorPressedInElevator

public boolean floorPressedInElevator(int floor)
                               throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorForController
Permits elevator controller to see if there is a request to a particular floor

Specified by:
floorPressedInElevator in interface ElevatorForController
Specified by:
floorPressedInElevator in interface ElevatorForUsers
Returns:
Whether there is currently a request to go to the specified floor (inside the elevator)
Throws:
java.lang.IllegalArgumentException - if the number of floors specified is not in range

installController

public void installController(ControllerForElevator controller)
                       throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorSpecification
Update the lift controller component - intended to be done by an engineer

Specified by:
installController in interface ElevatorSpecification
Parameters:
controller - is the new controller module that will decide the logic of the elevator movement
Throws:
java.lang.IllegalArgumentException - if the controller is null

noMoreRequestsAbove

public boolean noMoreRequestsAbove(int floor)
                            throws java.lang.IllegalArgumentException
Specified by:
noMoreRequestsAbove in interface ElevatorForController
Returns:
whether there is a request for a floor (inside the elevator) above the specified floor
Throws:
java.lang.IllegalArgumentException - if the number of floors specified is not in range

noMoreRequestsBelow

public boolean noMoreRequestsBelow(int floor)
                            throws java.lang.IllegalArgumentException
Specified by:
noMoreRequestsBelow in interface ElevatorForController
Returns:
whether there is a request for a floor (inside the elevator) above the specified floor
Throws:
java.lang.IllegalArgumentException - if the number of floors specified is not in range

pressDown

public void pressDown(int floor)
               throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorForUsers
Permits elevator users to request elevator to take them down

Specified by:
pressDown in interface ElevatorForUsers
Parameters:
floor - specifies the floor at which the down request is made
Throws:
java.lang.IllegalArgumentException - if the floor is not valid (from 1.. NUMBER_OF_FLOORS-1)

pressFloorInElevator

public void pressFloorInElevator(int floor)
                          throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorForUsers
Permits elevator users inside the elevator to request elevator to take them to a particular floor

Specified by:
pressFloorInElevator in interface ElevatorForUsers
Throws:
java.lang.IllegalArgumentException - if the number of floors specified is not in range

pressUp

public void pressUp(int floor)
             throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorForUsers
Permits elevator users to request elevator to take them up

Specified by:
pressUp in interface ElevatorForUsers
Parameters:
floor - specifies the floor at which the up request is made
Throws:
java.lang.IllegalArgumentException - if the floor is not valid (from 0.. NUMBER_OF_FLOORS-2)

topFloor

public int topFloor()
Specified by:
topFloor in interface ElevatorForController
Returns:
the number of the top floor

toString

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

updateFloor

public boolean updateFloor()
Description copied from interface: ElevatorSpecification
move to next floor (as decided by the controller)

Specified by:
updateFloor in interface ElevatorSpecification
Returns:
if the lift should stop at the next floor (as decided by the controller)

upPressedAtFloor

public boolean upPressedAtFloor(int floor)
                         throws java.lang.IllegalArgumentException
Description copied from interface: ElevatorForController
Permits elevator controller to see if a request to go up has been made at a specified floor

Specified by:
upPressedAtFloor in interface ElevatorForController
Specified by:
upPressedAtFloor in interface ElevatorForUsers
Parameters:
floor - specifies the floor at which the request is being checked
Throws:
java.lang.IllegalArgumentException - if the floor is not valid (from 0.. NUMBER_OF_FLOORS-2)