-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElevatorControls.java
executable file
·96 lines (85 loc) · 3.17 KB
/
ElevatorControls.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// PART OF THE MACHINE SIMULATION. DO NOT CHANGE.
package nachos.machine;
/**
* A set of controls that can be used by an elevator controller.
*/
public interface ElevatorControls {
/**
* Return the number of floors in the elevator bank. If <i>n</i> is the
* number of floors in the bank, then the floors are numbered <i>0</i>
* (the ground floor) through <i>n - 1</i> (the top floor).
*
* @return the number of floors in the bank.
*/
public int getNumFloors();
/**
* Return the number of elevators in the elevator bank. If <i>n</i> is the
* number of elevators in the bank, then the elevators are numbered
* <i>0</i> through <i>n - 1</i>.
*
* @return the numbe rof elevators in the bank.
*/
public int getNumElevators();
/**
* Set the elevator interrupt handler. This handler will be called when an
* elevator event occurs, and when all the riders have reaced their
* destinations.
*
* @param handler the elevator interrupt handler.
*/
public void setInterruptHandler(Runnable handler);
/**
* Open an elevator's doors.
*
* @param elevator which elevator's doors to open.
*/
public void openDoors(int elevator);
/**
* Close an elevator's doors.
*
* @param elevator which elevator's doors to close.
*/
public void closeDoors(int elevator);
/**
* Move an elevator to another floor. The elevator's doors must be closed.
* If the elevator is already moving and cannot safely stop at the
* specified floor because it has already passed or is about to pass the
* floor, fails and returns <tt>false</tt>. If the elevator is already
* stopped at the specified floor, returns <tt>false</tt>.
*
* @param floor the floor to move to.
* @param elevator the elevator to move.
* @return <tt>true</tt> if the elevator's destination was changed.
*/
public boolean moveTo(int floor, int elevator);
/**
* Return the current location of the elevator. If the elevator is in
* motion, the returned value will be within one of the exact location.
*
* @param elevator the elevator to locate.
* @return the floor the elevator is on.
*/
public int getFloor(int elevator);
/**
* Set which direction the elevator bank will show for this elevator's
* display. The <i>direction</i> argument should be one of the <i>dir*</i>
* constants in the <tt>ElevatorBank</tt> class.
*
* @param elevator the elevator whose direction display to set.
* @param direction the direction to show (up, down, or neither).
*/
public void setDirectionDisplay(int elevator, int direction);
/**
* Call when the elevator controller is finished.
*/
public void finish();
/**
* Return the next event in the event queue. Note that there may be
* multiple events pending when an elevator interrupt occurs, so this
* method should be called repeatedly until it returns <tt>null</tt>.
*
* @return the next event, or <tt>null</tt> if no further events are
* currently pending.
*/
public ElevatorEvent getNextEvent();
}