Repository navigation
Expand file tree
/
Copy pathAirTraffic.java
More file actions
53 lines (44 loc) · 2.13 KB
/
Copy pathAirTraffic.java
File metadata and controls
53 lines (44 loc) · 2.13 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
import java.util.ArrayList;
import java.util.List;
public class AirTraffic implements IAirTrafficController{
private List<AirCraft> _airCraft = new ArrayList<>();
private List<AirCraft> landingQueue = new ArrayList<>();
boolean runway = true;
public AirTraffic (){}
public void registerAirCraft(AirCraft airCraft){
_airCraft.add(airCraft);
landingQueue.add(airCraft);
System.out.println("Traffic Controller : Hello I'm adding you to List, Flight "+airCraft.getFlightName());
System.out.println("-------------------------------------------------------------------------------" + landingQueue);
}
public boolean checkRunway(AirCraft airCraft){
System.out.println("Traffic Controller : I recieved your reqirement Flight "+ airCraft.getFlightName()+ ", I'm checking the runway.");
if(airCraft == landingQueue.get(0)){
System.out.println("Traffic Controller : Flight "+ airCraft.getFlightName()+" you can landing on Runway 1.");
runway = true;
}else{
airCraft = landingQueue.get(0);
System.out.println("Traffic Controller : You must wait! Flight "+ airCraft.getFlightName()+ " is landing!");
runway =false;
}
return runway;
}
public void aircraftLanding(AirCraft airCraft){
System.out.println("Traffic Controller : Recieved flight "+ airCraft.getFlightName()+ ", I'm gonna notify that you are landing to the other pilots!");
System.out.println();
}
public void nextLanding(AirCraft airCraft){
System.out.println();
airCraft = landingQueue.get(0);
System.out.println("Traffic Controller : Flight "+ airCraft.getFlightName()+" you can landing on Runway 1.");
airCraft.land();
}
public void landingFinished(AirCraft airCraft){
landingQueue.remove(airCraft);
System.out.println("Traffic Controller : Recieved! I'm gonna notify to the next pilots. That you have already landed.");
if(landingQueue.size()>0){
nextLanding(airCraft);
System.out.println();
}
}
}