CAN ANYONE HELP ME WITH THIS PROBLEM? PLEASE WRITE IN C++, each problem need 3 f
ID: 3664889 • Letter: C
Question
CAN ANYONE HELP ME WITH THIS PROBLEM? PLEASE WRITE IN C++, each problem need 3 files. a header, a main, and function.
And also write comments to tell me what is what. Thank you very much.
Q3. (20 marks) Create a class called Flight that represents flight information of an airline company. The flight has the following attributes:
-Flight Number (e.g., AC300)
-Departure Time (Object of Class Time of Q1)
-Departure Date (Object of Class Date of Q2)
-Departure City (e.g., Montreal)
-Destination City (e.g., New York)
The class should have the following member functions,
- One or multiple constructors
- A copy constructor
- A function that prints out information about a flight
- Accessing functions
- A destructor
Create a driver to test the class. Submit the files: flight.h , flight.cpp, flighttest.cpp.
Q4. (20 marks) Create a class called Passenger that represents information of the passengers of the airline company. A passenger has the following attributes:
- Passenger Passport Number (e.g., AF300DE4)
- First Name (e.g., Eric)
- Last Name (e.g., Smith)
- Address Street (e.g., 105 Sherbrook Street)
- Telephone Number (e.g., 514
- 765
- 7676)
The class should have the following member functions:
- One or multiple constructors
- A copy constructor
- A function that prints out information about a passenger
- Accessing functions
- A destructor
Create a driver to test the class. Submit the files: passenger.h, passenger.cpp, passengertest.cpp.
Q5. (30 marks) We want to be able to book passengers on flights. Which modifications to the Passenger and Flight classes you need to make? Implement the changes. Submit the new classes and source code because each question has its own mark.
Use code comments to your program in the source code to explain your solutions.
Explanation / Answer
QUESTION 4:
HEADER CLASS FOR PASSENGER
class Passenger
{
private:
string first_Name;
string last_Name;
string passport_Number;
long int phone_Number;
string address;
public:
Passenger(); //default constructor
Passenger(string x, string y, string z, long int a, string b); //parameterized constructor
~Passenger(); //destructor
Passenger( const Passenger &obj); //copy constructor;
string get_firstName();
string get_lastName();
string get_address();
string get_passportNumber();
int get_phoneNo();
void set_firstName(string x);
void set_lastName(string y);
void set_address(string z);
void set_passportNumber(string a);
void set_phoneNo(int b);
void displayPassengerData();
};
FUNCTION CLASS OF PASSENGER
#include<iostream>
#include<cstring>
using namespace std;
Passenger::Passenger(string x, string y, string z, long int a, string b)
{
first_Name = x;
last_Name = y;
passport_Number = z;
phone_Number = a;
address = b;
}
Passenger::Passenger()
{
cout<<"Default Constructor"<<endl;
}
Passenger::~Passenger()
{
cout<<"Destructor"<<endl;
}
Passenger::Passenger( const Passenger &obj) //copy constructor;
{
first_Name = obj.first_Name;
last_Name = obj.last_Name;
passport_Number = obj.passport_Number;
phone_Number = obj.phone_Number;
address = obj.address;
}
string Passenger::get_firstName()
{
return first_Name;
}
string Passenger::get_lastName()
{
return last_Name;
}
string Passenger::get_address()
{
return address;
}
string Passenger::get_passportNumber()
{
return passport_Number;
}
int Passenger::get_phoneNo()
{
return phone_Number;
}
void Passenger::set_firstName(string x)
{
first_Name = x;
}
void Passenger::set_lastName(string y)
{
last_Name = y;
}
void Passenger::set_address(string z)
{
address = z;
}
void Passenger::set_passportNumber(string a)
{
passport_Number = a;
}
void Passenger::set_phoneNo(int b)
{
phone_Number = b;
}
void Passenger::displayPassengerData()
{
cout<<"Passenger Informat::"<<endl;
cout<<"FIRST NAME::"<<get_firstName()<<endl;
cout<<"LAST NAME::"<<get_lastName()<<endl;
cout<<"PASSPORT NUMBER::"<<get_passportNumber()<<endl;
cout<<"PHONE NUMBER::"<<get_phoneNo()<<endl;
cout<<"ADDRESS::"<<get_address()<<endl;
}
MAIN CLASS OF THE PASSENGER
int main()
{
Passenger P1("MAX", "WILLSON", "SFWEWER23", 1234567890, "310-G NEWYORK");
P1.displayPassengerData();
Passenger P2 = P1; //copy cosntructor called
P2.displayPassengerData();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.