#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Flight;

// Structure to store information about a passenger
class Passenger {
    string name;
    string email;
    string phone;

public:
    Passenger(string name, string email, string phone) {
        this->name = name;
        this->email = email;
        this->phone = phone;
    }

    void bookFlight(Flight* flight) {
        flight->passengers.push_back(*this);
    }

    string getName() const {
        return name;
    }

    string getEmail() const {
        return email;
    }

    string getPhone() const {
        return phone;
    }
};

// Base class for airlines
class Airline {
protected:
    string name;

public:
    Airline(string name) {
        this->name = name;
    }

    virtual double getTicketPrice() = 0; // pure virtual function

    string getName() {
        return name;
    }
};

// Derived class for economy airlines
class EconomyAirline : public Airline {
public:
    EconomyAirline() : Airline("Economy") {}

    double getTicketPrice() {
        return 100.00; // arbitrary ticket price for example purposes
    }
};

// Derived class for business airlines
class BusinessAirline : public Airline {
public:
    BusinessAirline() : Airline("Business") {}

    double getTicketPrice() {
        return 200.00; // arbitrary ticket price for example purposes
    }
};

// Derived class for first class airlines
class FirstClassAirline : public Airline {
public:
    FirstClassAirline() : Airline("First Class") {}

    double getTicketPrice() {
        return 300.00; // arbitrary ticket price for example purposes
    }
};

// Structure to store information about a flight
struct Flight {
    string flightNumber;
    string source;
    string destination;
    string date;
    string time;
    Airline* airline;
    vector<Passenger> passengers;

    Flight(string flightNumber, string source, string destination, string date, string time, Airline* airline) {
        this->flightNumber = flightNumber;
        this->source = source;
        this->destination = destination;
        this->date = date;
        this->time = time;
        this->airline = airline;
    }

    string getSource() {
        return source;
    }
};

// Class for the airport system
class AirportSystem {
public:
    vector<Flight> flights;

public:
  void bookFlight(string flightNumber, string destination, string date, string time, Airline* airline, vector<Passenger> passengers) {
    Flight flight(flightNumber, "", destination, date, time, airline);
    flight.passengers = passengers;
    flights.push_back(flight); // add the new flight object to the flights vector
    cout << "Flight " << flightNumber << " booked successfully!" << endl;
}



  void displayFlights() {
    for (int i = 0; i < flights.size(); i++) {
        Flight flight = flights[i];

        cout << "Flight Number: " << flight.flightNumber << endl;
        cout << "Source: " << flight.getSource() << endl;
        cout << "Destination: " << flight.destination << endl;
        cout << "Date: " << flight.date << endl;
        cout << "Time: " << flight.time << endl;
        cout << "Airline: " << flight.airline->getName() << endl;
        cout << "Ticket Price: $" << flight.airline->getTicketPrice() << endl;
        cout << "Passengers: " << endl;
        
        for (int j = 0; j < flight.passengers.size(); j++) {
            Passenger passenger = flight.passengers[j];
            cout << "Name: " << passenger.getName() << ", Email: " << passenger.getEmail() << ", Phone: " << passenger.getPhone() << endl;
        }
        cout << endl;
    }
}


    
};
int main() {
    AirportSystem airportSystem;

    // Create passengers
    Passenger passenger1("John Smith", "johnsmith@example.com", "1234567890");
    Passenger passenger2("Sarah Johnson", "sarahjohnson@example.com", "0987654321");

    // Create airlines
    Airline* economyAirline = new EconomyAirline();
    Airline* businessAirline = new BusinessAirline();
    Airline* firstClassAirline = new FirstClassAirline();

    // Create flights
    Flight* flight1 = new Flight("ABC123", "New York", "London", "2023-05-01", "10:00", economyAirline);
    Flight* flight2 = new Flight("DEF456", "London", "Paris", "2023-05-01", "11:30", businessAirline);
    Flight* flight3 = new Flight("GHI789", "Paris", "Tokyo", "2023-05-02", "01:00", firstClassAirline);

vector<Passenger> passengers1 = { passenger1 };
vector<Passenger> passengers2 = { passenger2 };
vector<Passenger> passengers3 = { passenger1, passenger2 };

airportSystem.flights.push_back(*flight1);
airportSystem.flights.push_back(*flight2);
airportSystem.flights.push_back(*flight3);


    // Display flight details
    airportSystem.displayFlights();

    // Clean up memory
    // delete economyAirline;
    // delete businessAirline;
    // delete firstClassAirline;
    // delete flight1;
    // delete flight2;
    // delete flight3;

    return 0;
}
correct this code