0% found this document useful (0 votes)
53 views

Flight Management System

This code defines a Flight class to store flight details like number, fuel, time, passengers, etc. It also defines a Flight_Management_System class to manage two queues - a landing queue and a takeoff queue. The class can land and enqueue flights in the landing queue. It can takeoff and dequeue flights from the takeoff queue. It also has methods to handle emergency landings by checking fuel levels and emergency takeoffs by removing from the takeoff queue. The main function gets user input to perform these operations and view the landing queue.

Uploaded by

Hamza Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Flight Management System

This code defines a Flight class to store flight details like number, fuel, time, passengers, etc. It also defines a Flight_Management_System class to manage two queues - a landing queue and a takeoff queue. The class can land and enqueue flights in the landing queue. It can takeoff and dequeue flights from the takeoff queue. It also has methods to handle emergency landings by checking fuel levels and emergency takeoffs by removing from the takeoff queue. The main function gets user input to perform these operations and view the landing queue.

Uploaded by

Hamza Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

//FA19-BSE-045

#include<iostream>
#include<string>
using namespace std;
struct Flight
{
string fnum;
int fuel;
int hours;
int minutes;
int passengers;
string city;
string destination_city;
int average_time;

};
class Flight_Management_System
{
private:
Flight LaQ1[20];
int LaQC1;
int counter;
Flight TaQ1[20];
int TaQC1,TaQC2;
int ET_QC1,ETQC2;
public:
Flight_Management_System()
{
counter=0;

}
// landing flight queue
LaQ1_flight( Flight frecord)
{

LaQ1[counter].fnum=frecord.fnum;
LaQ1[counter].fuel=frecord.fuel;
LaQ1[counter].hours=frecord.hours;
LaQ1[counter].minutes=frecord.minutes;
LaQ1[counter].city=frecord.city;
counter++;
}
void TaQ_flight( )
{
if(TaQ1isempty()==false)
{
int a=TaQ1[TaQC2];
for(int i=TaQC2;i<TaQC1;i++)
{
TaQ1[i]= TaQ1[i+1];

}
}
counter--; TaQC1--;
return a;
}
void EL_flight()
{
for(int i; i<=counter;i++)
{
if(LQ1[i].fuel< 1000)
{
cout<<" Emergency landing "<<LQ1[i].fnum;

}
}
}
void ET_flight()
{
int b=TaQ1[ET_QC1];
for(int i=ET_QC2;i<ET_QC1;i++)
{
TaQ1[i]= TaQ1[i+1];

}
}
counter--; ET_QC1--;
return b;

}
bool LaQ1isfull()
{
if(LaQC1>=20)
{
return true;
}
else
{
return false;
}

}
bool TaQ1isempty()
{
if(TaQC1<=0)
{
return true;
}
else
{
return false;
}
}
void view()
{
for(int i=0;i<counter;i++)
{
cout<<LaQ1[i].fnum;
}
}

};

int main()
{
Flight_Management_System FMS;
int choice;
string fnum,city;
int fuel,hours,minutes, passengers;
Flight frecord;
string destination_city;
while(choice!=0)
{
cout<<"\n\n\t Press 1 To : Land ";
cout<<"\n\n\t Press 2 To : Take off ";
cout<<"\n\n\t Press 3 To : Emergency Land ";
cout<<"\n\n\t Press 4 To : Emergency Take off ";
cout<<"\n\n\t Press 5 To : View reports ";
cout<<"\n\n\t Enter your Choice";
cin>>choice;

switch(choice)
{
case 1:
if(FMS.LaQ1_flight(frecord))
{
if(FMS.LaQ1isfull()==false)

cout<<"\nEnter the Flight Number";


cin>>fnum;
cout<<"\n Enter amount of fuel";
cin>>fuel;
if(fuel<=0 && fuel>100000)
{
cout<< " Sorry! Again Enter the amount ";
}
cout<<"\nEnter time in hours";
cin>>hours;
if(hours<=0 && hours >24)
{
cout<< " Sorry! Again Enter the hours ";
}
cout<<"Enter time in minutes";
cin>>minutes;
if(minutes<=0 && minutes>1440)
{
cout<< " Sorry! Again Enter the minutes ";
}
cout<<"\nEnter the Name of The city";
cin>>city;
cout<<"\nEnter the Number of passengers in a flight";
cin>> passengers;
}
break;
case 2:
if(FMS.TaQ1())
{

cout<<"Enter the Flight Number";


cin>>fnum;
cout<<"\n Enter amount of fuel";
cin>>fuel;
if(fuel<=0 && fuel>100000)
{
cout<< " Sorry! Again Enter the amount ";
}
cout<<"\nEnter time in hours";
cin>>hours;
if(hours<=0 && hours >24)
{
cout<< " Sorry! Again Enter the hours ";
}
cout<<"Enter time in minutes";
cin>>minutes;
if(minutes<=0 && minutes>1440)
{
cout<< " Sorry! Again Enter the minutes ";
}
cout<<"Enter the Name of The destination city";
cin>>destination_city;
cout<<"Enter the Number of passengers in a flight";
cin>> passengers;
}
break;
case 3:
FMS.EL_flight();
break;
case 4:
FMS. ET_flight();
break;
case 5:
FMS.view();
break;
}

}
return 0;
}

You might also like