-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunway
More file actions
63 lines (49 loc) · 1.69 KB
/
Runway
File metadata and controls
63 lines (49 loc) · 1.69 KB
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
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.LinkedList;
public class Runway {
// queue for taking off planes
private LinkedList<AirCraft> runwayQueue; //priority queue or linked list, which one?, first two lines in runway constructor
//queue for landing planes
private LinkedList<AirCraft> airBorneQueue; //priority queue or linked list, which one?, first two lines in runway constructor
private Counter counter;
private boolean isClear;
public Runway() {
runwayQueue = new PriorityQueue<AirCraft>(); //priority queue or linked list, which one?
airBorneQueue = new PriorityQueue<AirCraft>(); //priority queue or linked list, which one?
counter = new Counter(); //i think counters are supposed to be put into the lists with the aircraft, and it needs a name(String) passed as parameter
isClear = true;
}
public void run(){
for (AirCraft aircraft : runwayQueue.toArray(new AirCraft[runwayQueue.size()])){
aircraft.fly();
runwayQueue.add(aircraft);
aircraft.getWaitingTime());
}
for (AirCraft aircraft : airBorneQueue.toArray(new AirCraft[airBorneQueue.size()])) {
aircraft.fly();
airBorneQueue.add(aircraft);
aircraft.getWaitingTime());
}
}
public LinkedList<AirCraft> getAirborneQueue(){
return airBorneQueue;
}
public LinkedList<AirCraft> getRunwayQueue() {
return runwayQueue ;
}
public Counter getCounter() {
return counter;
}
public boolean isClear() {
return isClear;
}
public void setClear(boolean isClear) {
this.isClear = isClear;
}
public void clearRunway() {
counter.reset(); //changed from clear to reset (thats what i called it in my counter)
airBorneQueue.clear();
runwayQueue.clear();
}
}