-
Notifications
You must be signed in to change notification settings - Fork 1
/
ElevatorSystem.java
47 lines (39 loc) · 931 Bytes
/
ElevatorSystem.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
import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue;
public class ElevatorSystem {
// Reference to the building.
private Building _building;
// Queue of elevator requests.
private ArrayBlockingQueue<FloorRequest> _floorRequests = new ArrayBlockingQueue<FloorRequest>(20);
/**
* Constructor.
* @param building
*/
public ElevatorSystem(Building building){
// Initialize.
_building = building;
}
/**
* Add a new floor request.
* @param request
*/
public void addRequest(FloorRequest request){
// Add to queue.
_floorRequests.offer(request);
}
/**
* Remove an existing floor request.
* @param request
*/
public void removeRequest(FloorRequest request){
// Remove from queue.
_floorRequests.remove(request);
}
/**
* Getter for the floor requests.
* @return
*/
public ArrayBlockingQueue<FloorRequest> getFloorRequests(){
return _floorRequests;
}
}