Inside the FlightController class, you will define an object of type FlightSchedule which will
contain an array of 3 objects of type Flight. In your Flight objects, the constructor of these
objects will ask from the user for the inputs of: flight name, launch hour, launch minutes,
flight duration. The value of state of the Flight object will be assigned to “Idle” as a default
value in the constructor also and you will call the member function within the Flight class
which will calculate the landing time for your flight object by using the duration and the
launch time. Definition of Flight class will also contain the necessary getters and setters that
are given in the diagram and needed throughout your program.
In the constructor of your FlightController you will need to define a pointer that will point to
the adress of the FlightSchedule object you have created. You will send that pointer into the
functions launchSchedule and landingSchedule in your base classes and these functions will
perform a sorting operation between these three flight objects.
The launchController will check the launch times as in hours and minutes of the array of
objects that you have passed as a reference and will sort the array in ascending order. After
the sorting you will output the launch order of these flights in order. Similar approach will be
taken in the landingController and the landing order will be displayed as output after the
sorting is complete. Outputs will consist of flight name, landing hour, landing minute, flight’s
state and they will be printed from top down in order. Same thing will hold for both of the
landing and launch controllers.
________________________________________________________________________________
//this is my code for this hw but i confused for the arrays and inheritence classes please help
#include
using namespace std;
class flight{
private:
string flight_name;
int launch_hour,launch_min;
int duration;
int land_hour;
int land_min;
int time;
public:
flight(){
cout<"enter the="" name="" of="" the="">"enter>
cin>>flight_name;
cout<"enter the="" departure="" time="" of="" the="">"enter>
cin>>launch_hour>>launch_min;
cout<"enter the="" duration="" of="" the="" flight="" in="">"enter>
cin>>duration;
cout<><>
}
int calculate1(){
launch_hour*=60;
time=launch_hour+launch_min;//time=610
land_hour=time/60;//land hour=10
land_min=time-land_hour*60;
launch_hour/=60;
return time;
}
int calculate(){
launch_hour*=60;
time=duration+launch_hour+launch_min;//time=610
land_hour=time/60;//land hour=10
land_min=time-land_hour*60;
launch_hour/=60;
return time;
}
void print_launch(){
cout<><" launch="" at="">"><><" :="">"><><" flight="" state:="">"><>
}
void print_land(){
cout<><" landing="" at="">"><><" :="">"><><" flight="" state:="">"><>
}
};
void check(flight f1,flight f2,flight f3){
cout<"launch>"launch><>
if(f1.calculate1()<><><>
f1.print_launch();
f2.print_launch();
f3.print_launch();
}
else if(f2.calculate1()<><><>
f2.print_launch();
f1.print_launch();
f3.print_launch();
}
else if(f3.calculate1()<><><>
f3.print_launch();
f1.print_launch();
f2.print_launch();
}
else if(f3.calculate1()<><><>
f3.print_launch();
f2.print_launch();
f1.print_launch();
}
else if(f2.calculate1()<><><>
f2.print_launch();
f3.print_launch();
f1.print_launch();
}
else if(f1.calculate1()<><><>
f1.print_launch();
f3.print_launch();
f2.print_launch();
}
cout<><"landing>"landing><>
if(f1.calculate()<><><>
f1.print_land();
f2.print_land();
f3.print_land();
}
else if(f1.calculate()<><><>
f1.print_land();
f3.print_land();
f2.print_land();
}
else if(f2.calculate()<><><>
f2.print_land();
f3.print_land();
f1.print_land();
}
else if(f2.calculate()<><><>
f2.print_land();
f1.print_land();
f3.print_land();
}
else if(f3.calculate()<><><>
f3.print_land();
f1.print_land();
f2.print_land();
}
else if(f3.calculate()<><><>
f3.print_land();
f2.print_land();
f1.print_land();
}
}
int main(){
flight f1,f2,f3;
f1.calculate();
f2.calculate();
f3.calculate();
check(f1,f2,f3);
system("PAUSE");
}
Extracted text: cmpe225_hw1 (1).pdf 5 / 6 159% + Tam ekrandan çıkmak için F11 tuşuna basın Example Outputs Output 1 Enter the name of the flight: A Enter the departure time of the plane: 10 10 Enter the duration of the flight in minutes: 70 Enter the name of the flight: B Enter the departure time of the plane: 10 20 Enter the duration of the flight in minutes: 15 Enter the name of the flight: C Enter the departure time of the plane: 11 25 Enter the duration of the flight in minutes: 90 Launch Order A Launch at 10 : 10 Flight State: IDLE B Launch at 10 : 20 C Launch at 11 : 25 Flight State: IDLE Flight State: IDLE Landing Order B Landing at 10 : 35Flight State: IDLE A Landing at 11 : 20Flight State: IDLE C Landing at 12 : 55Flight State: IDLE Process exited after 24.81 seconds with return value e Press any key to continue
Extracted text: cmpe225_hw1 (1).pdf 2 / 6 135% + Assignment Write a program that will track certain information about the flights of aircrafts. You will create your program by referencing the structure given in the diagram (1). Class definitions, access specifiers, data members and member functions in your program must be coherent with the diagram. Certain essential variables for operations such as loops, flag values, counts etc. are not given in the diagram therefore you can define them as your own extra variables in the program. LaunchController LandingController -launchHour1: int - launchHour2: int - launchMin1: int landHour1: int - landHour2: int - landMin1: int - launchMin2: int landMin2: int + launchSchedule(FlightSchedule" ): void + landingSchedule(FlightSchedule" ): void Extends Extends FlightController # flight_schedule: FlightSchedule + FlightController() + flights: FlightSchedule" Flight |- flightName: string |- launchHour: int - launchMin: int -landHour: int -landMin: int FlightSchedule duration: int - flights[]: Flight - state: string + method(type): type + getlaunchHour(): int + getLaunchMin(): int + getlandHour(): int + getLandMin(): int + getState(): string + setState(string): void + calculatelanding(): void