|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmodels.FloorButtonsInElevator
public class FloorButtonsInElevator
Tested by JUnit_FloorButtonsInElevator
and Validation_FloorButtonsInElevator
For managing the state of the floor requests inside the elevator
(see ElevatorSpecification
)
Constructor Summary | |
---|---|
FloorButtonsInElevator(int numberOfFloors)
Initialises all floor requests (inside the elevator) to be false |
Method Summary | |
---|---|
void |
cancelFloorRequestInElevator(int floor)
Tested by JUnit_FloorButtonsInElevator.test_presses_cancels()
Update the state when a request for the specified floor has been served |
boolean |
floorPressedInElevator(int floor)
Tested by JUnit_FloorButtonsInElevator.test_presses_cancels() |
boolean |
invariant()
The following safety conditions are required: number of floors must be at least 2 the number of floor buttons is the same as the number of floors Tested by JUnit_FloorButtonsInElevator.test_invariant() |
boolean |
noMoreRequestsAbove(int floor)
Tested by JUnit_FloorButtonsInElevator.test_noMoreRequestsAbove() |
boolean |
noMoreRequestsBelow(int floor)
Tested by JUnit_FloorButtonsInElevator.test_noMoreRequestsBelow() |
void |
pressFloorInElevator(int floor)
Tested by JUnit_FloorButtonsInElevator.test_presses_cancels()
Update the state when a request is made for the specified floor (inside the elevator) |
java.lang.String |
toString()
Tested by JUnit_FloorButtonsInElevator.test_toString() Lists the floors that have been requested inside the elevator Typical output is of the form: Requested Floors Inside Elevator: 2 4 7 In this example, the floors requested (2,4 and 7) are listed in order and separated by single spaces |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FloorButtonsInElevator(int numberOfFloors) throws java.lang.IllegalArgumentException
numberOfFloors
- is the number of floors in the lift system
java.lang.IllegalArgumentException
- if the number of floors is <=1
InvariantBroken
- if not initialised in a safe stateMethod Detail |
---|
public void cancelFloorRequestInElevator(int floor) throws java.lang.IllegalArgumentException
JUnit_FloorButtonsInElevator.test_presses_cancels()
Update the state when a request for the specified floor has been served
floor
-
java.lang.IllegalArgumentException
- if the number of floors specified is not in rangepublic boolean floorPressedInElevator(int floor) throws java.lang.IllegalArgumentException
JUnit_FloorButtonsInElevator.test_presses_cancels()
floor
-
java.lang.IllegalArgumentException
- if the number of floors specified is not in rangepublic boolean invariant()
JUnit_FloorButtonsInElevator.test_invariant()
invariant
in interface HasInvariant
public boolean noMoreRequestsAbove(int floor) throws java.lang.IllegalArgumentException
JUnit_FloorButtonsInElevator.test_noMoreRequestsAbove()
floor
-
java.lang.IllegalArgumentException
- if the number of floors specified is not in rangepublic boolean noMoreRequestsBelow(int floor) throws java.lang.IllegalArgumentException
JUnit_FloorButtonsInElevator.test_noMoreRequestsBelow()
floor
-
java.lang.IllegalArgumentException
- if the number of floors specified is not in rangepublic void pressFloorInElevator(int floor) throws java.lang.IllegalArgumentException
JUnit_FloorButtonsInElevator.test_presses_cancels()
Update the state when a request is made for the specified floor (inside the elevator)
floor
-
java.lang.IllegalArgumentException
- if the number of floors specified is not in rangepublic java.lang.String toString()
JUnit_FloorButtonsInElevator.test_toString()
Requested Floors Inside Elevator: 2 4 7In this example, the floors requested (2,4 and 7) are listed in order and separated by single spaces
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |