1 // This is the class that manages all the flights
5 public class FlightList {
14 public void addFlightPlan(D2 d2, int time, StringTokenizer st) {
15 Flight newFlight=disjoint flightAdd new Flight(st.nextToken());
17 f.addElement(newFlight);
19 FlightPlan fAux=new FlightPlan();
20 Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());
21 newFlight.setAircraftType(aAux);
23 newFlight.setFlightType(st.nextToken());
24 Route rAux=new Route(Integer.parseInt(st.nextToken()));
25 for (int i=0;i<rAux.noFixes;i++)
26 rAux.addFix(d2,i,st.nextToken());
28 fAux.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
29 newFlight.setFlightPlan(fAux);
32 public String getFlightName(int index) {
33 Flight fAux=(Flight) f.elementAt(index);
37 public void amendFlightPlan(D2 d2, int time, StringTokenizer st) {
38 Flight fAux=getFlight(st.nextToken());
39 Route rAux=new Route(Integer.parseInt(st.nextToken()));
40 for (int i=0;i<rAux.noFixes;i++)
41 rAux.addFix(d2,i,st.nextToken());
42 fAux.fPlan.setRoute(rAux);
43 fAux.fPlan.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
46 public void amendFlightInfo(D2 d2, int time, StringTokenizer st) {
47 Flight fAux=getFlight(st.nextToken());
48 Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());
49 fAux.setAircraftType(aAux);
50 fAux.setFlightType(st.nextToken());
53 public void sendingAircraft(D2 d2, int time, StringTokenizer st) {
54 int noF=Integer.parseInt(st.nextToken());
61 for (int counter=0; counter<noF; counter++) {
64 Double.valueOf(st.nextToken()).doubleValue(),
65 Double.valueOf(st.nextToken()).doubleValue(),
66 Double.valueOf(st.nextToken()).doubleValue());
67 vel=new Velocity(Double.valueOf(st.nextToken()).doubleValue(),
68 Double.valueOf(st.nextToken()).doubleValue(),
69 Double.valueOf(st.nextToken()).doubleValue());
70 t=new Track(pos, vel);
71 nameFix=st.nextToken();
73 System.out.println(id+" Flight id: "+fAux.flightID);
75 System.out.println("Setting current fix ...");
76 fAux.fPlan.setCurrentFix(nameFix);
77 System.out.println("Sent flight "+
81 d2.getTrajectorySynthesizer().updateTrajectory(d2, time, fAux);
82 fAux.traject.printInfo();
86 public void removeFlightPlan(int time, StringTokenizer st) {
87 String id=st.nextToken();
89 while ((i<noFlights) && (((Flight) f.elementAt(i)).hasID(id))) i++;
90 if (i<noFlights) f.removeElementAt(i);
93 public Flight getFlight(String id) {
94 for( int i = 0; i < f.size(); ++i ) {
95 Flight fAux=(Flight) f.elementAt(i);
99 System.out.println("Flight not found - "+id);
104 public boolean anyPlanesAlive() {
105 for( int i = 0; i < f.size(); ++i ) {
106 Flight aAux=(Flight) f.elementAt(i);
107 Vector p1=aAux.traject.p;
108 Point4d pAux= (Point4d) p1.elementAt(0);
109 if (!pAux.outOfRange())
115 public void printInfo() {
116 System.out.println("\n\nThe number of flights:"+noFlights);
117 System.out.println("The flights are:");
118 for( int i = 0; i < f.size(); ++i ) {
119 Flight fAux=(Flight) f.elementAt(i);
120 System.out.println(fAux);