0% found this document useful (0 votes)
11 views55 pages

Working File

The document outlines a flight management system that includes functionalities for passengers and employees, such as booking tickets, searching for flights, and managing flight schedules. It employs various object-oriented programming concepts like inheritance and polymorphism. The code provided demonstrates the implementation of classes for managing flights, passengers, and airports.

Uploaded by

abdullah422847
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views55 pages

Working File

The document outlines a flight management system that includes functionalities for passengers and employees, such as booking tickets, searching for flights, and managing flight schedules. It employs various object-oriented programming concepts like inheritance and polymorphism. The code provided demonstrates the implementation of classes for managing flights, passengers, and airports.

Uploaded by

abdullah422847
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

SCREENSHOTS OF WORKING

WHEN PASSENGER
➢ Displaying flight schedule randomly

➢ Booking tickets
➢ Searching for flights

➢ Ticket verification
WHEN EMPLOYEE
➢ Secret Password Validation

➢ If incorrect
➢ Can access arrival/departure flights

➢ Can book tickets


➢ Can manage flights

➢ If Add

➢ If Remove
OOP CONCEPTS USED
➢ Constructors
➢ Destructors
➢ Inheritance

➢ Multiple inheritance
➢ Multilevel inheritance

➢ Pure virtual function

➢ Overridden
➢ Virtual function

➢ Containership

➢ Polymorphism
Airport Terminal Sytem Code
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <conio.h>
using namespace std;
class FlightManagement
{
protected:
string runways[2];
bool runwayClosed[2];
string aircraftTypes[5];
int seatsAvailable[20];
string flightCodes[20];
public:
FlightManagement()
{
//cout<<" Flight constructor"<<endl
runways[0] = "36R/18L";
runways[1] = "36L/18R";
runwayClosed[0] = false;
runwayClosed[1] = false;
aircraftTypes[0] = "Boeing 777";
aircraftTypes[1] = "Boeing 747";
aircraftTypes[2] = "Airbus A350";
aircraftTypes[3] = "Airbus A380";
aircraftTypes[4] = "Airbus A330";

flightCodes[0] = "EK7001";
flightCodes[1] = "KE8001";
flightCodes[2] = "IR2002";
flightCodes[3] = "QR5002";
flightCodes[4] = "UL6002";
flightCodes[5] = "NH9001";
flightCodes[6] = "NZ6001";
flightCodes[7] = "QF5001";
flightCodes[8] = "BA2001";
flightCodes[9] = "AA3001";
flightCodes[10] = "AC4001";
flightCodes[11] = "MU1002";
flightCodes[12] = "FG3002";
flightCodes[13] = "SU4002";
flightCodes[14] = "TG8002";
flightCodes[15] = "MH9002";
flightCodes[16] = "PR1003";
flightCodes[17] = "GA2003";
flightCodes[18] = "SV1001";
flightCodes[19] = "SA1007";

for(int i = 0; i < 20; i++)


{
seatsAvailable[i] = rand() % 9 + 1;
}
}
int getSeatsAvailable(string flightCode)
{
for (int i = 0; i < 20; i++)
{
if (flightCodes[i]==flightCode)
{
return seatsAvailable[i];
}
}
return 0;
}
void decrementSeats(string flightCode)
{
for (int i = 0; i < 20; i++)
{
if (flightCodes[i]==flightCode)
{
if (seatsAvailable[i] > 0)
{
seatsAvailable[i]--;
}
else
{
cout << "No seats available to book for flight " << flightCode <<
"." << endl;
}
return;
}
}
cout << "Flight code not found!" << endl;
}
void randomCloseRunway()
{
int i = rand() % 2;
runwayClosed[i] = true;
cout << "Runway " << runways[i] << " is closed for maintenance!" << endl;
}
bool isRunwayClosed(int i)
{
return runwayClosed[i];
}
string getRunway(int i)
{
return runways[i];
}
string getRandomAircraft()
{
int i = rand() % 5;
return aircraftTypes[i];
}
string getRandomRunway()
{
int i = rand() % 2;
return runways[i];
}
void displayAllotmentMessage()
{
string aircraft = getRandomAircraft();
string runway = getRandomRunway();
cout << "Your flight has been allotted to " << aircraft << " on runway " <<
runway << "." << endl;
}
~FlightManagement()
{
//cout<<" flight destructor "<<endl
}
};
class Airport
{
protected:
string airportID;
string destination;
string place;
public:
Airport()
{
//cout<<" Default Airport constructor "<<endl;
airportID = "";
destination = "";
place = "";
}
Airport(string id, string pla, string dest)
{
//cout<<" Parameterised airport constructor "<<endl;
airportID = id;
destination = dest;
place = pla;
}

virtual void displayFlightDetails() = 0;


~Airport()
{
//cout<<" Default Airport constructor "<<endl;
}
};
class Luggage
{
protected:
float weight;
public:
Luggage()
{
//cout<<"Default Luggage constructor"<<endl;
weight = 0;
}
Luggage(float w)
{
//cout<<"Parameterised Luggage constructor"<<endl;
weight = w;
}
bool isWeightAcceptable()
{
return weight <= 22;
}
~Luggage()
{
//cout<<"Destructor"<<endl;
}
};

class Passenger
{
protected:
int passengerID;
string name;
string status;
float luggageInfo;
public:
Passenger()
{
//cout<<"Default passenger constructor"<<endl;
passengerID = 0;
name = "";
status = "Not Checked-in";
luggageInfo = 0.0;
}
Passenger(int id, string n, float luggage)
{
//cout<<"Parameterised passenger constructor"<<endl;
passengerID = id;
name = n;
status = "Ticket Confirmed!";
luggageInfo = luggage;
}
virtual void displayDetails()
{
//cout<<"Yeh wo virtaul function"<<endl;
cout << "Passenger ID: " << passengerID << endl;
cout << "Name: " << name << endl;
cout << "Status: " << status << endl;
cout << "Luggage Info: " << luggageInfo << endl;
}
void setStatus(string s)
{
status = s;
}
int getID()
{
return passengerID;
}
string getName()
{
return name;
}
float getLuggageInfo()
{
return luggageInfo;
}
~Passenger()
{
//cout<<"Destructor"<<endl;
}
};
class CheckedInPassenger : public Passenger, public Luggage
{
public:
CheckedInPassenger()
{
//cout<<"Default constructor"<<endl;
}
CheckedInPassenger(int id, string n, float lw): Passenger(id,
n,lw),Luggage(lw)
{
//cout<<"PArameterised constructor"<<endl;
}
void displayCheckedInDetails()
{
displayDetails();
cout << "Luggage Weight: " << weight << " kg" << endl;
}
~CheckedInPassenger()
{
//cout<<"Destructor"<<endl;
}
};
class BoardingPass : public Passenger
{
protected:
string seatNumber;
int gateNumber;
public:
BoardingPass()
{
//cout<<"Default constructor"<<endl;
}
BoardingPass(int id, string n, string s,int g,float l) :
Passenger(id,n,l),seatNumber(s), gateNumber(g)
{
//cout<<"Parameterised constructor"<<endl;
}
void displayDetails() override
{
Passenger::displayDetails();
cout << "Seat Number: " << seatNumber << endl;
cout << "Gate Number: " << gateNumber << endl;
}
void displayBoardingPass()
{
displayDetails();
}
~BoardingPass()
{
//cout<<"Destructor"<<endl;
}
};
class AirportSystem : public Airport
{
protected:
int seatsAvailable;
string arrivalFlights[9];
string departureFlights[11];
string alltemp[20];
string disariv[9];
string disdept[11];
FlightManagement m;
public:
AirportSystem() : Airport()
{
//cout<<"Default constructor"<<endl;
seatsAvailable = rand() % 9 + 1;
initializeFlights();
}
AirportSystem(string id, string pla, string dest) : Airport(id, pla, dest)
{
//cout<<"Parameterised constructor"<<endl;
seatsAvailable = rand() % 9 + 1;
initializeFlights();
}
void displayFlightDetails() override
{
cout << "Airport ID: " << airportID << endl;
cout << "Airport City: " << place << endl;
cout << "Destination: " << destination << endl;
}
string getArrivalFlight(int i)
{
if (i >= 0 && i < 9)
{
return arrivalFlights[i];
}
return "";
}
string getDepartureFlight(int i)
{
if (i >= 0 && i < 11)
{
return departureFlights[i];
}
return "";
}
void initializeFlights()
{
arrivalFlights[0] = "From Dubai (EK7001) - Arrival: 8:00 AM";
arrivalFlights[1] = "From South Korea (KE8001) - Arrival: 11:00 PM";
arrivalFlights[2] = "From Iran (IR2002) - Arrival: 2:00 PM";
arrivalFlights[3] = "From Qatar (QR5002) - Arrival: 5:00 AM";
arrivalFlights[4] = "From Sri Lanka (UL6002) - Arrival: 5:00 AM";
arrivalFlights[5] = "From Japan (NH9001) - Arrival: 5:00 PM";
arrivalFlights[6] = "From New Zealand (NZ6001) - Arrival: 10:00 AM";
arrivalFlights[7] = "From Australia (QF5001) - Arrival: 6:00 AM";
arrivalFlights[8] = "From Saudi Arabia (SV1001) - Arrival: 3:00 PM";

departureFlights[0] = "Flight to London (BA2001) - Departure: 9:55


AM";
departureFlights[1] = "Flight to United States (AA3001) - Departure: 5:00
PM";
departureFlights[2] = "Flight to Canada (AC4001) - Departure: 6:00
AM";
departureFlights[3] = "Flight to China (MU1002) - Departure: 1:00 PM";
departureFlights[4] = "Flight to Afghanistan (FG3002) - Departure: 12:00
PM";
departureFlights[5] = "Flight to Russia (SU4002) - Departure: 8:00 AM";
departureFlights[6] = "Flight to Thailand (TG8002) - Departure: 10:00
PM";
departureFlights[7] = "Flight to Malaysia (MH9002) - Departure: 1:00 AM";
departureFlights[8] = "Flight to Philippines (PR1003) - Departure: 4:30 PM";
departureFlights[9] = "Flight to Indonesia (GA2003) - Departure: 9:00
AM";
departureFlights[10] = "Flight to Saudi Arabia (SA1007) - Departure:
10:00 AM";
for (int i = 0; i < 9; i++)
{
int t = rand()%9;
swap(arrivalFlights[i], arrivalFlights[t]);
}
for (int i = 0; i < 11; i++)
{
int t = rand()%11;
swap(departureFlights[i], departureFlights[t]);
}
}
void displayFlightSchedule()
{
cout <<
"==================================================================
==========================" << endl;
cout << "| Route | Airline name: | Flight code: | Time: |
Status |" << endl;
cout <<
"==================================================================
==========================" << endl;
string flightSchedules[20];
flightSchedules[0] = "From Dubai | Emirates | EK7001 |
8:00 AM | On Time ";
flightSchedules[1] = "From South Korea | Korean Air | KE8001 |
11:00 PM | Delayed ";
flightSchedules[2] = "From Iran | Iran Air | IR2002 | 2:00
PM | On Time ";
flightSchedules[3] = "From Qatar | Qatar Airways | QR5002 |
5:00 AM | On Time ";
flightSchedules[4] = "From Sri Lanka | SriLankan Airlines | UL6002
| 5:00 AM | Delayed ";
flightSchedules[5] = "From Japan | All Nippon Airways | NH9001
| 5:00 PM | On Time ";
flightSchedules[6] = "From New Zealand | Air New Zealand | NZ6001
| 10:00 AM | Landed ";
flightSchedules[7] = "From Australia | Qantas | QF5001 |
6:00 AM | On Time ";
flightSchedules[8] = "From Saudi Arabia| Saudi Airline | SV1001 |
3:00 PM | Cleared ";
flightSchedules[9] = "From London | British Airways | BA2001 |
9:55 AM | On Time ";
flightSchedules[10] = "From Chicago | American Airlines | AA3001
| 5:00 PM | On Time ";
flightSchedules[11] = "From Toronto | Air Canada | AC4001 |
6:00 AM | On Time ";
flightSchedules[12] = "From Beijing | China Airlines | MU1002 |
1:00 PM | On Time ";
flightSchedules[13] = "From Kabul | Afghan Airlines | FG3002 |
12:00 PM | On Time ";
flightSchedules[14] = "From Moscow | Aeroflot | SU4002 |
8:00 AM | On Time ";
flightSchedules[15] = "From Bangkok | Thai Airways | TG8002
| 10:00 PM | On Time ";
flightSchedules[16] = "From Kuala Lumpur| Malaysia Airlines | MH9002
| 1:00 AM | On Time ";
flightSchedules[17] = "From Manila | Philippine Airlines | PR1003
| 4:30 PM | Delayed ";
flightSchedules[18] = "From Jakarta | Garuda Indonesia | GA2003
| 9:00 AM | On Time ";
flightSchedules[19] = "From Dammam | Saudi Airline | SA1007
| 10:00 AM | On Time ";

for (int i = 0; i < 20; i++)


{
int t = rand() % 20;
swap(flightSchedules[i], flightSchedules[t]);
}
for (int i = 0; i < 9; i++)
{
cout << "| " << flightSchedules[i] << " |" << endl;
}
cout <<
"==================================================================
==========================" << endl;
}
void displayArrivalFlights()
{
cout << "Available Arrival Flights to Pakistan:" << endl;
for (int i = 0; i < 7; i++)
{
cout << arrivalFlights[i] << endl;
disariv[i]=arrivalFlights[i];
}
}
void displayDepartureFlights()
{
cout << "Available Departure Flights:" << endl;
for (int i = 0; i < 7; i++)
{
cout << departureFlights[i] << endl;
disdept[i]=departureFlights[i];
}
}
void displayFlightDetailsByCode(string flightCode)
{
cout << "Booking ticket for flight: " << flightCode << endl;
if (flightCode == "EK7001" || flightCode == "ek7001")
{
cout << "Flight Details! \n Airlines: Emirates \n Flight Code: EK7001 \n
Departure time: 4:00 AM \n Arrival on Lahore International Airport: 8:00 AM" <<
endl;
}
else if(flightCode == "KE8001" || flightCode == "ke8001")
{
cout << "Flight Details! \n Airlines: Korean Air \n Flight Code: KE8001
\n Departure time: 7:00 PM \n Arrival on Lahore International Airport: 11:00 PM"
<< endl;
}
else if (flightCode == "IR2002" || flightCode == "ir2002")
{
cout << "Flight Details! \n Airlines: Iran Air \n Flight Code: IR2002 \n
Departure time: 10:00 AM \n Arrival on Lahore International Airport: 2:00 PM" <<
endl;
}
else if (flightCode == "QR5002" || flightCode == "qr5002")
{
cout << "Flight Details! \n Airlines: Qatar Airways \n Flight Code:
QR5002 \n Departure time: 3:00 AM \n Arrival on Lahore International Airport:
5:00 AM" << endl;
}
else if (flightCode == "UL6002" || flightCode == "ul6002")
{
cout << "Flight Details! \n Airlines: SriLankan Airlines \n Flight Code:
UL6002 \n Departure time: 11:30 PM \n Arrival on Lahore International Airport:
5:00 AM" << endl;
}
else if (flightCode == "NH9001" || flightCode == "nh9001")
{
cout << "Flight Details! \n Airlines: All Nippon Airways \n Flight Code:
NH9001 \n Departure time: 9:00 AM \n Arrival on Lahore International Airport:
5:00 PM" << endl;
}
else if (flightCode == "NZ6001" || flightCode == "nz6001")
{
cout << "Flight Details! \n Airlines: Air New Zealand \n Flight Code:
NZ6001 \n Departure time: 3:00 PM \n Arrival on Lahore International Airport:
10:00 AM" << endl;
}
else if (flightCode == "QF5001" || flightCode == "qf5001")
{
cout << "Flight Details! \n Airlines: Qantas \n Flight Code: QF5001 \n
Departure time: 11:00 PM \n Arrival on Lahore International Airport: 6:00 AM" <<
endl;
}
else if (flightCode == "BA2001" || flightCode == "ba2001")
{
cout << "Flight Details! \n Airlines: British Airways \n Flight Code:
BA2001 \n Departure time: 9:55 AM \n Arrival on London International Airport:
6:00 PM" << endl;
}
else if (flightCode == "AA3001" || flightCode == "aa3001")
{
cout << "Flight Details! \n Airlines: American Airlines \n Flight Code:
AA3001 \n Departure time: 5:00 PM \n Arrival on Chicago International Airport:
10:00 PM" << endl;
}
else if (flightCode == "AC4001" || flightCode == "ac4001")
{
cout << "Flight Details! \n Airlines: Air Canada \n Flight Code: AC4001
\n Departure time: 6:00 AM \n Arrival on Toronto International Airport: 12:00
PM" << endl;
}
else if (flightCode == "MU1002" || flightCode == "mu1002")
{
cout << "Flight Details! \n Airlines: China Eastern Airlines \n Flight
Code: MU1002 \n Departure time: 1:00 PM \n Arrival on Beijing International
Airport: 6:00 PM" << endl;
}
else if (flightCode == "FG3002" || flightCode == "fg3002")
{
cout << "Flight Details! \n Airlines: Ariana Afghan Airlines \n Flight
Code: FG3002 \n Departure time: 12:00 PM \n Arrival on Kabul International
Airport: 4:00 PM" << endl;
}
else if (flightCode == "SU4002" || flightCode == "su4002")
{
cout << "Flight Details! \n Airlines: Aeroflot \n Flight Code: SU4002 \n
Departure time: 8:00 AM \n Arrival on Sheremetyevo International Airport: 12:00
PM" << endl;
}
else if (flightCode == "TG8002" || flightCode == "tg8002")
{
cout << "Flight Details! \n Airlines: Thai Airways \n Flight Code:
TG8002 \n Departure time: 10:00 PM \n Arrival on Suvarnabhumi International
Airport: 6:00 AM" << endl;
}
else if (flightCode == "MH9002" || flightCode == "mh9002")
{
cout << "Flight Details! \n Airlines: Malaysia Airlines \n Flight Code:
MH9002 \n Departure time: 1:00 AM \n Arrival on Kuala Lumpur International
Airport: 7:00 AM" << endl;
}
else if (flightCode == "PR1003" || flightCode == "pr1003")
{
cout << "Flight Details! \n Airlines: Philippine Airlines \n Flight Code:
PR1003 \n Departure time: 4:30 PM \n Arrival on Ninoy Aquino International
Airport: 10:30 PM" << endl;
}
else if (flightCode == "GA2003" || flightCode == "ga2003")
{
cout << "Flight Details! \n Airlines: Garuda Indonesia \n Flight Code:
GA2003 \n Departure time: 9:00 AM \n Arrival on Soekarno–Hatta International
Airport: 3:00 PM" << endl;
}
else if (flightCode == "SV1001" || flightCode == "sv1001")
{
cout << "Flight Details! \n Airlines: Saudi Airline \n Flight Code:
SV1001 \n Departure time: 10:00 AM \n Arrival on King Fahd International
Airport: 3:00 PM" << endl;
}
else if (flightCode == "SA1007" || flightCode == "sa1007")
{
cout << "Flight Details! \n Airlines: Saudi Airline \n Flight Code:
SA1007 \n Departure time: 10:00 AM \n Arrival on King Fahd International
Airport: 3:00 PM" << endl;
}
else
{
cout << "Invalid flight code!" << endl;
}
}
int getAvailableSeats()
{
return seatsAvailable;
}
void bookTicket(string flightCode, Luggage luggage, Passenger passenger)
{
if (m.getSeatsAvailable(flightCode) <= 0)
{
cout << "No seats left for flight " << flightCode << ". Please wait for the
next flight." << endl;
return;
}
if (luggage.isWeightAcceptable())
{
cout << "Booking successful for " << passenger.getName() << " on
flight " << flightCode << "." << endl;
m.decrementSeats(flightCode);
BoardingPass boardingPass(passenger.getID(), passenger.getName(),
"A" + to_string(10 - m.getSeatsAvailable(flightCode)), 1,
passenger.getLuggageInfo());
boardingPass.displayBoardingPass();
cout << endl;
m.displayAllotmentMessage();
cout << endl;
cout << "Remaining seats for flight " << flightCode << ": " <<
m.getSeatsAvailable(flightCode) << endl;
passenger.setStatus("Checked-in");
}
else
{
cout << "Booking failed due to luggage weight." << endl;
}
}
void searchFlightByCountry(string country)
{
cout << "Searching for flights to/from " << country << "..." << endl;
string flightSchedules[20];
flightSchedules[0] = "From Dubai | Emirates | EK7001 |
8:00 AM | On Time ";
flightSchedules[1] = "From South Korea | Korean Air | KE8001 |
11:00 PM | Delayed ";
flightSchedules[2] = "From Iran | Iran Air | IR2002 |
2:00 PM | On Time ";
flightSchedules[3] = "From Qatar | Qatar Airways | QR5002
| 5:00 AM | On Time ";
flightSchedules[4] = "From Sri Lanka | SriLankan Airlines | UL6002
| 5:00 AM | Delayed ";
flightSchedules[5] = "From Japan | All Nippon Airways | NH9001
| 5:00 PM | On Time ";
flightSchedules[6] = "From New Zealand | Air New Zealand | NZ6001
| 10:00 AM | Landed ";
flightSchedules[7] = "From Australia | Qantas | QF5001 |
6:00 AM | On Time ";
flightSchedules[8] = "From Saudi Arabia| Saudi Airline | SV1001
| 3:00 PM | Cleared ";
flightSchedules[9] = "From London | British Airways | BA2001
| 9:55 AM | On Time ";
flightSchedules[10] = "From Chicago | American Airlines | AA3001
| 5:00 PM | On Time ";
flightSchedules[11] = "From Toronto | Air Canada | AC4001 |
6:00 AM | On Time ";
flightSchedules[12] = "From Beijing | China Airlines | MU1002
| 1:00 PM | On Time ";
flightSchedules[13] = "From Kabul | Afghan Airlines | FG3002
| 12:00 PM | On Time ";
flightSchedules[14] = "From Moscow | Aeroflot | SU4002 |
8:00 AM | On Time ";
flightSchedules[15] = "From Bangkok | Thai Airways | TG8002
| 10:00 PM | On Time ";
flightSchedules[16] = "From Kuala Lumpur| Malaysia Airlines | MH9002
| 1:00 AM | On Time ";
flightSchedules[17] = "From Manila | Philippine Airlines | PR1003
| 4:30 PM | Delayed ";
flightSchedules[18] = "From Jakarta | Garuda Indonesia | GA2003
| 9:00 AM | On Time ";
flightSchedules[19] = "From Dammam | Saudi Airline | SA1007
| 10:00 AM | On Time ";

string flights[20];
flights[0] = "Dubai";
flights[1] = "South Korea";
flights[2] = "Iran";
flights[3] = "Qatar";
flights[4] = "Sri Lanka";
flights[5] = "Japan";
flights[6] = "New Zealand";
flights[7] = "Australia";
flights[8] = "Saudi Arabia";
flights[9] = "London";
flights[10] = "Chicago";
flights[11] = "Toronto";
flights[12] = "Beijing";
flights[13] = "Kabul";
flights[14] = "Moscow";
flights[15] = "Bangkok";
flights[16] = "Kuala Lumpur";
flights[17] = "Manila";
flights[18] = "Jakarta";
flights[19] = "Dammam";
for(int i=0;i<19;i++)
if(country==flights[i])
{
cout<<" Flight found! "<<endl;
cout <<
"==================================================================
==========================" << endl;
cout << "| Route | Airline name: | Flight code: | Time:
| Status |" << endl;
cout <<
"==================================================================
==========================" << endl;
cout << "| "<<flightSchedules[i]<<" | "<<endl;
cout <<
"==================================================================
==========================" << endl;
}
}
void addarriveflights(string country)
{
cout << "Adding flight of " << country << "..." << endl;
arrivalFlights[0] = "From Dubai (EK7001) - Arrival: 8:00 AM";
arrivalFlights[1] = "From South Korea (KE8001) - Arrival: 11:00 PM";
arrivalFlights[2] = "From Iran (IR2002) - Arrival: 2:00 PM";
arrivalFlights[3] = "From Qatar (QR5002) - Arrival: 5:00 AM";
arrivalFlights[4] = "From Sri Lanka (UL6002) - Arrival: 5:00 AM";
arrivalFlights[5] = "From Japan (NH9001) - Arrival: 5:00 PM";
arrivalFlights[6] = "From New Zealand (NZ6001) - Arrival: 10:00 AM";
arrivalFlights[7] = "From Australia (QF5001) - Arrival: 6:00 AM";
arrivalFlights[8] = "From Saudi Arabia (SV1001) - Arrival: 3:00 PM";

string flights[9];
flights[0] = "Dubai";
flights[1] = "South Korea";
flights[2] = "Iran";
flights[3] = "Qatar";
flights[4] = "Sri Lanka";
flights[5] = "Japan";
flights[6] = "New Zealand";
flights[7] = "Australia";
flights[8] = "Saudi Arabia";
cout<<endl;
cout<<"Arrival flight Updated Schedule!"<<endl;
cout<<endl;
for(int i=0;i<9;i++)
{
if(country==flights[i])
{
cout<<arrivalFlights[i]<<endl;
}
}
for(int i=0;i<9;i++)
{
cout<<disariv[i]<<endl;
}
}
void adddepartflights(string country)
{
cout << "Adding flight of " << country << "..." << endl;
departureFlights[0] = "Flight to London (BA2001) - Departure: 9:55 AM";
departureFlights[1] = "Flight to United States (AA3001) - Departure: 5:00
PM";
departureFlights[2] = "Flight to Canada (AC4001) - Departure: 6:00 AM";
departureFlights[3] = "Flight to China (MU1002) - Departure: 1:00 PM";
departureFlights[4] = "Flight to Afghanistan (FG3002) - Departure: 12:00
PM";
departureFlights[5] = "Flight to Russia (SU4002) - Departure: 8:00 AM";
departureFlights[6] = "Flight to Thailand (TG8002) - Departure: 10:00 PM";
departureFlights[7] = "Flight to Malaysia (MH9002) - Departure: 1:00 AM";
departureFlights[8] = "Flight to Philippines (PR1003) - Departure: 4:30 PM";
departureFlights[9] = "Flight to Indonesia (GA2003) - Departure: 9:00 AM";
departureFlights[10] = "Flight to Saudi Arabia (SA1007) - Departure: 10:00
AM";

string flights[10];
flights[0] = "London";
flights[1] = "United States";
flights[2] = "Canada";
flights[3] = "China";
flights[4] = "Afghanistan";
flights[5] = "Russia";
flights[6] = "Thailand";
flights[7] = "Malaysia";
flights[8] = "Philippines";
flights[9] = "Indonesia";
flights[10] = "Saudi Arabia";
cout<<endl;
cout<<"Departure flight Updated Schedule!"<<endl;
cout<<endl;
for(int i=0;i<9;i++)
{
if(country==flights[i])
{
cout<<departureFlights[i]<<endl;
}
}
for(int i=0;i<9;i++)
{
cout<<disdept[i]<<endl;
}
}
void removearriveflights(string country)
{
cout << "Removing flight of " << country << "..." << endl;
arrivalFlights[0] = "From Dubai (EK7001) - Arrival: 8:00 AM";
arrivalFlights[1] = "From South Korea (KE8001) - Arrival: 11:00 PM";
arrivalFlights[2] = "From Iran (IR2002) - Arrival: 2:00 PM";
arrivalFlights[3] = "From Qatar (QR5002) - Arrival: 5:00 AM";
arrivalFlights[4] = "From Sri Lanka (UL6002) - Arrival: 5:00 AM";
arrivalFlights[5] = "From Japan (NH9001) - Arrival: 5:00 PM";
arrivalFlights[6] = "From New Zealand (NZ6001) - Arrival: 10:00 AM";
arrivalFlights[7] = "From Australia (QF5001) - Arrival: 6:00 AM";
arrivalFlights[8] = "From Saudi Arabia (SV1001) - Arrival: 3:00 PM";

string flights[9];
flights[0] = "Dubai";
flights[1] = "South Korea";
flights[2] = "Iran";
flights[3] = "Qatar";
flights[4] = "Sri Lanka";
flights[5] = "Japan";
flights[6] = "New Zealand";
flights[7] = "Australia";
flights[8] = "Saudi Arabia";

for (int i = 0; i < 9; i++)


{
arrivalFlights[i]=disariv[i];
}
cout<<endl;
cout << "Arrival flight Updated Schedule!" << endl;
cout<<endl;
for (int i = 0; i < 9; i++)
{
if (arrivalFlights[i].find(country) == string::npos)
{
cout << disariv[i] << endl;
}
}
}
void removedepartureflights(string country)
{
cout << "Removing flight of " << country << "..." << endl;
departureFlights[0] = "Flight to London (BA2001) - Departure: 9:55
AM";
departureFlights[1] = "Flight to United States (AA3001) - Departure: 5:00
PM";
departureFlights[2] = "Flight to Canada (AC4001) - Departure: 6:00 AM";
departureFlights[3] = "Flight to China (MU1002) - Departure: 1:00 PM";
departureFlights[4] = "Flight to Afghanistan (FG3002) - Departure:
12:00 PM";
departureFlights[5] = "Flight to Russia (SU4002) - Departure: 8:00 AM";
departureFlights[6] = "Flight to Thailand (TG8002) - Departure: 10:00 PM";
departureFlights[7] = "Flight to Malaysia (MH9002) - Departure: 1:00
AM";
departureFlights[8] = "Flight to Philippines (PR1003) - Departure: 4:30
PM";
departureFlights[9] = "Flight to Indonesia (GA2003) - Departure: 9:00
AM";
departureFlights[10] = "Flight to Saudi Arabia (SA1007) - Departure:
10:00 AM";

string flights[10];
flights[0] = "London";
flights[1] = "United States";
flights[2] = "Canada";
flights[3] = "China";
flights[4] = "Afghanistan";
flights[5] = "Russia";
flights[6] = "Thailand";
flights[7] = "Malaysia";
flights[8] = "Philippines";
flights[9] = "Indonesia";
flights[10] = "Saudi Arabia";

for (int i = 0; i < 9; i++)


{
departureFlights[i]=disdept[i];
}
cout<<endl;
cout<<"Departure flight Updated Schedule!"<<endl;
cout<<endl;
for (int i = 0; i < 9; i++)
{
if (departureFlights[i].find(country) == string::npos)
{
cout << disdept[i] << endl;
}
}
}
~AirportSystem()
{
//cout<<"Destructor"<<endl;
}
};
class InternationalAirportSystem : public AirportSystem
{
public:
InternationalAirportSystem()
{
//cout<<"Default constructor"<<endl;
}
InternationalAirportSystem(string id, string pla, string dest) :
AirportSystem(id, pla, dest)
{
//cout<<"Parameterised constructor"<<endl;
}
void displayInternationalFlights()
{
cout << "Displaying international flights..." << endl;
}
};
class SearchTicket
{
protected:
AirportSystem& airport;
public:
SearchTicket(AirportSystem& airportSystem) : airport(airportSystem)
{
//cout<<"Parameterised constructor"<<endl;
}
void searchFlight(string country)
{
airport.searchFlightByCountry(country);
}
~SearchTicket()
{
//cout<<"default constructor"<<endl;
}
};
class AirportOperations
{
private:
FlightManagement m;
protected:
AirportSystem airport;
public:
AirportOperations(string id, string place, string dest) : airport(id, place,
dest) {}
void run()
{
string userType;
cout << "Are you a Passenger or airport employee? ";
cin >> userType;
if (userType == "EMPLOYEE" || userType == "employee" || userType ==
"Employee")
{
cout << "Enter Airport ID: ";
char ch;
int i = 0;
string airportID;
while (i < 4)
{
ch = getch();
cout << "*";
airportID += ch;
i++;
}
cout << endl;
string choice;
if (airportID == "LHE" || airportID == "IATA" || airportID == "OPLA")
{
cout<<" Access Granted!"<<endl;
airport.displayFlightDetails();
cout << "Do you want to check flight schedule? (yes/no) ";
cin >> choice;
if (choice == "YES" || choice == "yes" || choice == "Yes")
{
cout << "Arrival or departure flights? (arrival/departure): ";
cin >> choice;
if (choice == "arrival" || choice == "ARRIVAL" || choice == "Arrival")
{
airport.displayArrivalFlights();
}
else if (choice == "departure" || choice == "DEPARTURE" ||
choice == "Departure")
{
airport.displayDepartureFlights();
}
}
cout << "Do you want to book a flight? (yes/no): ";
cin >> choice;
if (choice == "yes" || choice == "YES" || choice == "Yes")
{
int numPassengers;
cout << "Enter the number of passengers (up to 10): ";
cin >> numPassengers;
if (numPassengers > 10)
{
cout << "Maximum number of passengers is 10." << endl;
numPassengers = 10;
}
for (int i = 0; i < numPassengers; i++)
{
if (airport.getAvailableSeats() <= 0)
{
cout << "No seats left. Please wait for the next flight." <<
endl;
break;
}
else
{
cout << endl;
cout << "Enter details for passenger " << (i + 1) << ":" <<
endl;
cout << "Enter your desired flight code: ";
string flightCode;
cin >> flightCode;
cout << "Enter your luggage weight (kg): ";
float luggageWeight;
cin >> luggageWeight;
Luggage luggage(luggageWeight);
cout << "Enter your Passenger ID: ";
int passengerID;
cin >> passengerID;
cout << "Enter your name: ";
string passengerName;
cin.ignore();
getline(cin, passengerName);
cout << endl;
Passenger passenger(passengerID, passengerName,
luggageWeight);
airport.bookTicket(flightCode, luggage, passenger);
}
}
cout<<endl;
m.displayAllotmentMessage();
cout<<endl;
}
cout << "Do you want to change flight schedule? (yes/no) ";
cin >> choice;
string s;
if (choice == "YES" || choice == "yes" || choice == "Yes")
{
cout << "You want to add flight or remove? (add/remove) ";
cin >> choice;
if (choice == "ADD" || choice == "add" || choice == "Add")
{
cout << "You want to ADD arrival or departure flight?
(arrival/departure): ";
cin >> s;
if (s == "arrival" || s == "ARRIVAL" || s == "Arrival")
{
cout << "Enter the desired country name to add: ";
cin.ignore();
getline(cin, s);
airport.addarriveflights(s);
}
else if (s == "departure" || s == "DEPARTURE" || s ==
"Departure")
{
cout << "Enter the desired country name to add: ";
cin.ignore();
getline(cin, s);
airport.adddepartflights(s);
}
}
else if (choice == "REMOVE" || choice == "remove" || choice ==
"Remove")
{
cout << "You want to remove arrival or departure flight?
(arrival/departure): ";
cin >> s;
if (s == "arrival" || s == "ARRIVAL" || s == "Arrival")
{
cout << "Enter the desired country name to remove: ";
cin.ignore();
getline(cin, s);
airport.removearriveflights(s);
}
else if (s == "departure" || s == "DEPARTURE" || s == "Departure")
{
cout << "Enter the desired country name to remove: ";
cin.ignore();
getline(cin, s);
airport.removedepartureflights(s);
}
}
}
}
else
{
cout << "Invalid Airport ID!" << endl;
cout<<" Access denied!"<<endl;
}
}
else
{
string choice;
SearchTicket searchTicket(airport);
cout << "Do you want to check flight schedule? (yes/no): ";
cin >> choice;
if (choice == "yes" || choice == "YES")
{

airport.displayFlightSchedule();
cout << "Do you want to book tickets? (yes/no): ";
cin >> choice;
if (choice == "yes" || choice == "YES")
{
cout << "You want to book arrival flight or departure flight?
(arrival/departure): ";
cin >> choice;
if (choice == "arrival" || choice == "ARRIVAL")
{
airport.displayArrivalFlights();
}
else if (choice == "departure" || choice == "DEPARTURE")
{
airport.displayDepartureFlights();
}
int numPassengers;
cout << "Enter the number of passengers (up to 10): ";
cin >> numPassengers;
if (numPassengers > 10)
{
cout << "Maximum number of passengers is 10." << endl;
numPassengers = 10;
}
for (int i = 0; i < numPassengers; i++)
{
if (airport.getAvailableSeats() <= 0)
{
cout << "No seats left" << endl;
break;
}
cout << endl;
cout << "Enter details for passenger " << (i + 1) << ":" << endl;
cout << "Enter your desired flight code: ";
string flightCode;
cin >> flightCode;
cout << "Enter your luggage weight (kg): ";
float luggageWeight;
cin >> luggageWeight;
Luggage luggage(luggageWeight);
cout << "Enter your Passenger ID: ";
int passengerID;
cin >> passengerID;
cout << "Enter your name: ";
string passengerName;
cin.ignore();
getline(cin, passengerName);
cout << endl;
Passenger passenger(passengerID, passengerName,
luggageWeight);
airport.bookTicket(flightCode, luggage, passenger);
}
}
}
cout << "Do you want to search for a flight by country? (yes/no): ";
cin >> choice;
if (choice == "yes" || choice == "YES")
{
cout << "Enter the country name to search for flights: ";
string countryName;
cin.ignore();
getline(cin, countryName);
searchTicket.searchFlight(countryName);
}
cout << "Do you want to check your ticket status? (yes/no): ";
cin >> choice;
if (choice == "yes" || choice == "YES")
{
cout << "Enter your ticket number (e.g., A1 to A9): ";
string ticketNumber;
cin >> ticketNumber;
if (ticketNumber[0] == 'A' && ticketNumber.length() == 2 &&
ticketNumber[1] >= '1' && ticketNumber[1] <= '9')
{
if (rand() % 2 == 0)
{
cout << "Ticket number " << ticketNumber << " is booked." <<
endl;
}
else
{
cout << "Ticket number " << ticketNumber << " is not booked."
<< endl;
}
}
else
{
cout << "Invalid ticket number format." << endl;
}
}
}
}
};
int main()
{
srand(time(0));
AirportOperations operations("LHE", "Lahore Pakistan", "Various
Destinations");
operations.run();
Airport* ptr = new InternationalAirportSystem("Gujranwala", "International
City", "Global Destinations");
ptr->displayFlightDetails();
return 0;
}

You might also like