-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATC.java
48 lines (38 loc) · 1.17 KB
/
ATC.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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Queue;
class Sortbycodey implements Comparator<Flight> {
// Method
// Sorting in ascending order of code
public int compare(Flight a, Flight b) {
return a.code.compareTo(b.code);
}
}
public class ATC {
// f 7 characters, the first 4 ACC, the following 3 characters
// are numbers from 0 to 999, filled with zeros from the front. //related to the
// hashtable in ACC
private String code;
ATC(String code) {
this.code = code;
}
boolean atc_running_full = false;
Flight flg_running;
ArrayList<Flight> atc_waiting = new ArrayList<Flight>();
ArrayList<Flight> compare_atc = new ArrayList<Flight>(); //collecting here before entering the ready queue
Queue<Flight> readyqueue = new LinkedList<Flight>();
public String get_ATC_code() {
return code;
}
public void set_ATC_code(String code) {
this.code = code;
}
public void add_to_readyQueue() {
Collections.sort(compare_atc, new Sortbycodey());
while (!compare_atc.isEmpty()) {
this.readyqueue.add(compare_atc.remove(0));
}
}
}