Question
This is a C++ Question: You are expected to design a program that calculates and outputs a passengers boarding time. Passengers boarding time will be
This is a C++ Question:
You are expected to design a program that calculates and outputs a passengers boarding time. Passengers boarding time will be distributed based on their flight ticket class. There are three types of classes; Economy Class, Business Class and First Class passengers. In your program, you will first design an inheritance based on an abstract class called Passenger. Passenger class will have a function within called calcBoardingTime which is a pure virtual function. This function will calculate different boarding times for each of these three child classes. It will also have a void return type. This function will calculate the boarding time via a built-in try-catch mechanism that you are going to implement. In the try-catch block within the function, you are going to check the number of passengers. The number of passengers will be held for each of passenger classes (first, business and economic) with their respected static counter variables. There can be maximum 10 first class passengers, 10 business class passengers and 20 economy class passengers. Inside the try-catch block, check if the number of passengers are valid. If so, you will call a function which is defined outside of all classes called findTime(). This findTime() function will accept two parameters within. One for taking the boardingTime variable (which is a string variable defined inside the parent class, holds the time in XX:XX format. The other variable will be the number of minutes that has passed. The number of minutes will be different for each of these passengers. As an example, consider first class passengers. Inside the calcBoardingTime() function for a first class passenger, number of minutes will be calculated as firstClassCount*4. This means that there will be total of 4 minutes reserved for each first class passenger. Therefore, the second first class passenger will have a boarding time until 10:08 (Assuming the boarding starts at 10:00, first first class passenger has time until 10:04, second one will have time until 10:08 etc.). Same goes on for business class and economy class passengers but difference within the function will have different minute*count calculations. Business class passengers each will have 3 minutes for boarding. Economy class passengers will have 2 minutes allowed for boarding. After passing the parameters, findTime() function will calculate the total amount of time passed for each passenger and will return the final time as a string to where the function was called and assign the value for the boarding time variable that is within the parent class. By doing so, this will allow each object to have their respective boarding times held within. Lastly, you will have another function in the program called displayPassengerInfo(). This function will accept a parent-class type pointer as parameter and will print the information of each passenger uniquely. Test your program and see different types of passengers boarding times displayed based on their ticket type. Create passenger objects within your main function. Each passenger object will have its passenger type assigned automatically as First Class , Business Class etc. An example output is given below the document. You can add any necessary implementations and functions/headers on your own in order to complete the program by staying true to this document.
Sample Run:
***Passenger Information***
Adralei Male First Class 10:04
John Male First Class 10:08
Anthony Male Businees Class 10:11
Eva Female Economy Class 10:13
Hanna Female Economy Class 10:15
Charlotte Female First Class 10:19
Bruce Male Economy Class 10:21
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started