Working File
Working File
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
➢ If Add
➢ If Remove
OOP CONCEPTS USED
➢ Constructors
➢ Destructors
➢ Inheritance
➢ Multiple inheritance
➢ Multilevel inheritance
➢ 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";
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";
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";
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";
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;
}