#include <iostream>
#include <string>

class Passenger {
    std::string firstName;
    std::string lastName;
    int passportNamber;

   public:
    Passenger() = default;

    Passenger(std::string firstName, std::string lastName, int passportNamber) {
        this->firstName = firstName;
        this->lastName = lastName;
        this->passportNamber = passportNamber;
    }

    void info() {
        std::cout << firstName << ", " << lastName << ", " << passportNamber << "\n";
    }
};

class Plane {
    std::string model;
    int year;
    size_t seat_count;

   public:
    Passenger* passengers;
    size_t passengerAmount;

    Plane() = default;

    Plane(std::string model, int year, size_t seat_count) {
        passengerAmount = 0;
        passengers = new Passenger[0];
        this->model = model;
        this->year = year;
        this->seat_count = seat_count;
    }

    void info() {
        std::cout << model << ", " << year << ", " << seat_count << '\n';
    }

    void PassengerInformation() {
        for (size_t i = 0; i < passengerAmount; i++) {
            passengers[i].info();
        }
    }

    void addPassager(Passenger passenger) {
        Passenger* new_passengers = new Passenger[passengerAmount + 1];
        for (size_t i = 0; i < passengerAmount; i++) {
            new_passengers[i] = passengers[i];
        }
        new_passengers[passengerAmount] = passenger;
        delete[] passengers;
        passengers = new_passengers;
        passengerAmount++;
    }

    void removePassenger(size_t n) {
        Passenger* new_passengers = new Passenger[passengerAmount - 1];

        for (size_t i = 0; i < n; i++) {
            new_passengers[i] = passengers[i];
        }

        for (size_t j = n + 1; j < passengerAmount; j++) {
            new_passengers[j - 1] = passengers[j];
        }
        delete[] passengers;
        passengers = new_passengers;
        passengerAmount -= 1;
    }
};

class FlyCompany {
    Plane* planes;
    size_t planeAmount;

   public:
    FlyCompany() {
        planes = new Plane[0];
        planeAmount = 0;
    }

    void addPlane(Plane plane) {
        Plane* new_planes = new Plane[planeAmount + 1];
        for (size_t i = 0; i < planeAmount; i++) {
            new_planes[i] = planes[i];
        }
        new_planes[planeAmount] = plane;
        delete[] planes;
        planes = new_planes;
        planeAmount++;
    }

    void deletePlane(size_t n) {
        Plane* new_planes = new Plane[planeAmount - 1];

        for (size_t i = 0; i < n; i++) {
            new_planes[i] = planes[i];
        }

        for (size_t j = n + 1; j < planeAmount; j++) {
            new_planes[j - 1] = planes[j];
        }
        delete[] planes;
        planes = new_planes;
        planeAmount--;
    }

    void register_passenger(Passenger passanger, size_t plane_index) {
        planes[plane_index].addPassager(passanger);
    }

    void unregister_passenger(size_t passenger_id, size_t plane_index) {
        planes[plane_index].removePassenger(passenger_id);
    }

    void plane_info() {
        for (size_t i = 0; i < planeAmount; i++) {
            planes[i].info();
        }
    }

    void passenger_info() {
        for (size_t i = 0; i < planeAmount; i++) {
            planes[i].PassengerInformation();
        }
    }
};

int main() {
    FlyCompany company;

    Plane boing("Boing", 2000, 10);
    Plane plane2("Plane2", -5, 3);

    Passenger petiya("Петя", "Васильев", 112245326);
    Passenger pasha("Паша", "Александров", 531930186);
    Passenger vova("Вова", "Клепцов", 913573127);

    company.addPlane(boing);
    company.addPlane(plane2);

    company.register_passenger(petiya, 0);
    company.register_passenger(pasha, 1);
    company.register_passenger(vova, 1);

    company.passenger_info();
    company.plane_info();
    std::cout << '\n';

    company.deletePlane(0);
    company.unregister_passenger(0, 0);

    company.passenger_info();
    company.plane_info();
}
