1 // This is the class that manages all the flights
5 public class FlightList {
15 public void addFlight(int index, Flight flight) {
16 f.addElement(index,flight);
20 public void addFlightPlan(D2 d2, int time, StringTokenizer st) {
21 Flight newFlight=disjoint flightAdd new Flight(st.nextToken());
23 f.addElement(newFlight);
25 FlightPlan fAux=new FlightPlan();
26 Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());
27 newFlight.setAircraftType(aAux);
29 newFlight.setFlightType(st.nextToken());
30 Route rAux=new Route(Integer.parseInt(st.nextToken()));
31 for (int i=0;i<rAux.noFixes;i++)
32 rAux.addFix(d2,i,st.nextToken());
34 fAux.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
35 newFlight.setFlightPlan(fAux);
38 public String getFlightName(int index) {
39 Flight fAux=(Flight) f.elementAt(index);
43 public void amendFlightPlan(D2 d2, int time, StringTokenizer st) {
44 Flight fAux=getFlight(st.nextToken());
45 Route rAux=new Route(Integer.parseInt(st.nextToken()));
46 for (int i=0;i<rAux.noFixes;i++)
47 rAux.addFix(d2,i,st.nextToken());
48 fAux.fPlan.setRoute(rAux);
49 fAux.fPlan.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
52 public void amendFlightInfo(D2 d2, int time, StringTokenizer st) {
53 Flight fAux=getFlight(st.nextToken());
54 Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());
55 fAux.setAircraftType(aAux);
56 fAux.setFlightType(st.nextToken());
59 public void sendingAircraft(D2 d2, int time, StringTokenizer st) {
60 int noF=Integer.parseInt(st.nextToken());
67 for (int counter=0; counter<noF; counter++) {
70 Double.valueOf(st.nextToken()).doubleValue(),
71 Double.valueOf(st.nextToken()).doubleValue(),
72 Double.valueOf(st.nextToken()).doubleValue());
73 vel=new Velocity(Double.valueOf(st.nextToken()).doubleValue(),
74 Double.valueOf(st.nextToken()).doubleValue(),
75 Double.valueOf(st.nextToken()).doubleValue());
76 t=new Track(pos, vel);
77 nameFix=st.nextToken();
79 System.out.println(id+" Flight id: "+fAux.flightID);
81 System.out.println("Setting current fix ...");
82 fAux.fPlan.setCurrentFix(nameFix);
83 System.out.println("Sent flight "+
87 d2.getTrajectorySynthesizer().updateTrajectory(d2, time, fAux);
88 fAux.traject.printInfo();
92 public void removeFlightPlan(int time, StringTokenizer st) {
93 String id=st.nextToken();
95 while ((i<noFlights) && (((Flight) f.elementAt(i)).hasID(id))) i++;
96 if (i<noFlights) f.removeElementAt(i);
99 public Flight getFlight(String id) {
100 for( int i = 0; i < f.size(); ++i ) {
101 Flight fAux=(Flight) f.elementAt(i);
105 System.out.println("Flight not found - "+id);
110 public boolean anyPlanesAlive() {
111 for( int i = 0; i < f.size(); ++i ) {
112 Flight aAux=(Flight) f.elementAt(i);
113 Vector p1=aAux.traject.p;
114 Point4d pAux= (Point4d) p1.elementAt(0);
115 if (!pAux.outOfRange())
121 public void printInfo() {
122 System.out.println("\n\nThe number of flights:"+noFlights);
123 System.out.println("The flights are:");
124 for( int i = 0; i < f.size(); ++i ) {
125 Flight fAux=(Flight) f.elementAt(i);
126 System.out.println(fAux);