Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program to implement in c++ code. --- Create a class called Airline to represent the airline company for which the system is created. The class

Program to implement in c++ code.

---Create a class called Airline to represent the airline company for which the system is created. The class has the following data members:

  • name (string)
  • address (string)
  • telephone (string)
  • collection of flights (could be an array of Flight objects)
  • collection of passengers (could be an array of Passenger objects) - collection of bookings (could be an array of Booking objects)

The class should have at least the following member functions:

  • One or more constructors
  • Necessary getters and setters
  • Make a booking (book a flight for a passenger). Make sure two passengers are not seated on the same seat.
  • Cancel a booking
  • Return the seat number of a passenger on a specific flight
  • Return the number of passengers for a given flight
  • Return the number of flights for a given destination city
  • Return the number of passengers going to a given destination
  • Return the number of passengers travelling from a given city
  • Return if two flights depart at the same time
  • Return the list of flights that travel to a given city
  • Return the list of flights that travel from a given city
  • A function that prints general information about the airline company - A destructor

Deliverables: classes Booking,Passenger and flight.

airline.h, airline.cpp, testairline.cpp.

  • Program

    Time.h

    #pragma once #include using namespace std; //Class fo time setting class Time { //Data members private: int hour; int min; int sec; //Member functions public: Time(); void setTime(int h,int m,int s); void printTime(); };

    Time.cpp

    //Implementation of time #include "Time.h" #include //Constructor Time::Time(){} //setter void Time::setTime(int h, int m, int s) { hour = h; min = m; sec = s; } //getter void Time :: printTime() { cout << to_string(hour) + ":" + to_string(min) + ":" + to_string(sec); }

    Date.h

    #pragma once #include using namespace std; //Crete a class named date to get date class Date { //Data members private: int day; int mon; int year; //Member functions public: Date(); void setDate(int d, int m, int y); string getDate(); };

    Date.cpp

    //Date inplementation #include "Date.h" //Default constructor Date::Date(){} //Set date void Date::setDate(int d, int m, int y) { day = d; mon = m; year = y; } //Get date string Date::getDate() { return (to_string(day)+"-"+to_string(mon)+"-"+to_string(year)); }

    Passenger.h

    #pragma once #include #include #include "Date.h" //Class to create a passenger using namespace std; class Passenger { //Member variables private: int PassengerID; string Name; string Address; string Tel; Date DateOfBirth; //Member functions public: Passenger(); Passenger(int,string); void setPassenger(int, string); int getPassengerId(); string getName(); string getAddress(); void setAddress(string); void setTel(string); string getTel(); string getDateOfBirth(); void setDateOfBirth(int, int, int); void printPassengerInfo(); ~Passenger(); };

    Passenger.cpp

    //Implementation of passenger #include "Passenger.h" //Parameterized constructor Passenger::Passenger(int pid, string name) { PassengerID = pid; Name = name; } //Getter for id int Passenger::getPassengerId() { return PassengerID; } //Getter for name string Passenger::getName() { return Name; } //Getter for address string Passenger::getAddress() { return Address; } //Setter for address void Passenger::setAddress(string addr) { Address = addr; } //Telephone setter void Passenger::setTel(string tel) { Tel = tel; } //Get telephone number string Passenger::getTel() { return Tel; } //Get passenger DOB string Passenger::getDateOfBirth() { return DateOfBirth.getDate(); } //Set DOB void Passenger::setDateOfBirth(int d, int m, int y) { DateOfBirth.setDate(d, m, y); } //Print passenget information void Passenger::printPassengerInfo() { cout << "Passenger's ID: " << PassengerID<< endl; cout << "Passenger's Name: " << Name<< endl; cout << "Passenger's Address: " << Address<< endl; cout << "Passenger's Tel: " << Tel<< endl; cout << "Passenger's Date of birth: " << getDateOfBirth() << endl; } //Destructor Passenger::~Passenger(){} //Setter for id and name of the passenger void Passenger::setPassenger(int pid, string name) { PassengerID = pid; Name = name; } //Default constructor Passenger::Passenger(){}

    Flight.h

    #pragma once #include #include #include "Date.h" #include "Time.h" using namespace std; //Create a class for flight details class Flight { //Member variables private: string id, city; Time depTime, arrTime; Date depDate, arrDate; //Member functions public: Flight(); void setId(string); void setCity(string); void setDate(int, int, int, int, int, int); void setTime(int, int, int, int, int, int); void printDate(); ~Flight(); };

    Flight.cpp

    #include "Flight.h" //Constructor Flight::Flight(){} //Set fight id void Flight::setId(string idd) { id = idd; } //Set city to travel void Flight::setCity(string ct) { city = ct; } //Set flight date of flight void Flight::setDate(int arrD, int arrM, int arrY, int depD, int depM, int depY) { arrDate.setDate(arrD, arrM, arrY); depDate.setDate(depD, depM, depY); } //Set flight arrival,departure times void Flight::setTime(int arrH, int arrM, int arrS, int depH, int depM, int depS) { arrTime.setTime(arrH, arrM, arrS); depTime.setTime(depH,depM, depS); } //Print flight details void Flight::printDate() { cout << "Flight Details" << endl << "---------------" << endl; cout << "ID: " << id << endl; cout << "City: " << city << endl; cout << "Arrival Time: "; arrTime.printTime(); cout << endl; cout << "Departure Time: "; depTime.printTime(); cout << endl; cout << "Arrival Date: " << arrDate.getDate() << endl; cout << "Departure Date: " << depDate.getDate() << endl; } //Destructor Flight::~Flight(){}

    booking.h

    #pragma once #include "Passenger.h" #include "Flight.h" //Class for book a flight class Booking { //Member variables private: int BookingNumber; Passenger passenger; Flight flight; string SeatNumber; //Member functions public: Booking(); Booking(int bNum,string sNum); void setPassenger(int, string, string, string, int d, int m, int y); void setFilght(string, string,int,int,int, int, int, int, int, int, int, int, int, int); int getbNum(); string getSNum(); void PrintBookingInfo(); ~Booking(); };

    booking.cpp

    //Implementation #include "booking.h" //Default constructor Booking::Booking(){} //Parameterized constructor Booking::Booking(int bNum, string sNum) { BookingNumber = bNum; SeatNumber = sNum; } //Set passenger details void Booking::setPassenger(int id, string name, string add, string tel, int d,int m,int y) { passenger.setPassenger(id, name); passenger.setAddress(add); passenger.setTel(tel); passenger.setDateOfBirth(d,m,y); } //Set flightdetails void Booking::setFilght(string id, string ct, int arrH, int arrM, int arrS, int depH, int depM, int depS, int arrD, int arrMon, int arrY, int depD, int depMon, int depY) { flight.setId(id); flight.setCity(ct); flight.setDate(arrD, arrMon, arrY, depD, depMon, depY); flight.setTime(arrH, arrM, arrS, depH, depM, depS); } //Getters int Booking::getbNum() { return BookingNumber; } string Booking::getSNum() { return SeatNumber; } //Print booking info void Booking::PrintBookingInfo() { cout << "Booking Number: " << BookingNumber << endl; passenger.printPassengerInfo(); flight.printDate(); cout << "Seat Number: " << SeatNumber<< endl; } //destructor Booking::~Booking(){}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

4. What decision would you make and why?

Answered: 1 week ago

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago