Question: in c++ with working code Airplane Fleet Application Program This project involves designing and creating a C++ program that contains three C++ classes and uses
in c++ with working code













Airplane Fleet Application Program This project involves designing and creating a C++ program that contains three C++ classes and uses inheritance, as described below. The base class (parent class) is the Airplane class. The CargoPlane and PassengerPlane classes are derived classes (child classes) of the Airplane class. A UML diagram of this class relationship is shown below: It is important to note that this is NOT multiple inheritance. Design Requirements 1. The program must be designed using the three classes that are described in the previous section of this document. Any submission that does not conform to this requirement will receive a grade of ZERO. 2. The program must be organized as a "Command Loop" program, similar to the Command Loop sample program that we discussed during an earlier class. (Refer to the Ch06_sample_code_CommandLoop... resource in the Sample Code section of Moodle.) 3. The program must implement the following interactive commands: \begin{tabular}{ll} a & Add a new airplane to the fleet. \\ f & Fly a plane in the fleet. \\ h & print Help text. \\ p & Print current fleet information. \\ r & Quit (end the program). \\ r & Remove airplane from the fleet. \end{tabular} (Specific requirements for each command are stated in the Requirements for Interactive Commands section of this document.) 4. The program must create a vector of pointers to Airplane objects: the main function must have a local variable defined as shown here: vector fleet; The fleet vector becomes an argument for the functions that process each of the user commands. 5. Each Airplane object must be dynamically allocated (using the C++ new operation) when the user executes the "a" command. Class Specification Files (provided with the assignment) There are three class specification files (Airplane.h, CargoPlane.h, and PassengerPlane.h) provided to the student as part of the project assignment. Ideally the student should not need to modify these files in order to complete the project. Obviously, if the student does modify any of these files, then the modified versions must be submitted to Moodle with the rest of the source code files. Airplane.h This file declares the member variables and functions of the Airplane class. The actual code is included in this file for the destructor function only. The student must implement code for the constructor functions and for other member functions in the Airplane.cpp file. CargoPlane.h This file declares the member variables and functions of the CargoPlane class. The actual code is included in this file for the constructor and destructor functions only. The student must implement code for the other member functions in the CargoPlane.cpp file. PassengerPlane.h This file declares the member variables and functions of the PassengerPlane class. The actual code is included in this file for the constructor and destructor functions only. The student must implement code for other member functions in the PassengerPlane.cpp file. Requirements for Interactive Commands \begin{tabular}{|l|l|} \hline Command & \multicolumn{1}{|c|}{ Requirement } \\ \hline a & Add a new Airplane to the fleet: \\ 1. Output a prompt, asking the user to specify the type of airplane they wish \\ to add (c = cargo, p = passenger) \\ 2. Ask the user to specify the various details about the airplane: \\ - Manufacturer \\ - Airplane model \\ - The year the airplane was built \\ - Cargo planes have a maximum cargo weight. \\ - Passenger planes have a maximum number of passengers. \\ 3. The constructor function for the Airplane class must assign to each new \\ Airplane object a unique value for the \\ member variable. For the lifetime of that particular Airplane object, its \\ airplane_ID variable does not change after the constructor function has set \\ it. \\ Furthermore, once a particular value has been assigned for the airplane_ID \\ member variable of some Airplane object, that value cannot be re-used as \\ long as the program is running. The program keeps track of the \\ airplane_ID values that have been assigned since the program started \\ running. (An example of how to do this is available in the Employee. h \\ source code provided with Lab15a, and is also discussed in Chapter 14 of \\ the textbook.) \\ CAUTION: Do not confuse the airplane_ID variable of an Airplane \\ object with the current index into the fleet vector. Once an object is \\ created, its airplane_ID variable will never change, but the contents of the \\ vector mav change denendino on the seauence of user commands. \end{tabular} Sample Interactive Session In the sample data on the next several pages, what the user types is shown in bold font. In actuality, what the user types would have the same text format as the rest of the output. Sample Interactive Session Which airplane do you want to fly? 0 Length of flight (hours) ? 12 Airplane 0 not found. Enter command (or 'h' for help): a Enter type of airplane ( c= cargo, p= passenger): c Enter name of manufacturer: Boeing Enter model: B747-400F Enter year built: 1996 Enter flight hours: 73200 Enter maximum cargo weight: 102500 New airplane : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 addNewAirplane: Size of fleet =1 Enter command (or 'h' for help): p Current fleet contains 1 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 Enter command (or 'h' for help): a Enter type of airplane ( c= cargo, p= passenger): p Enter name of manufacturer: Lockeed Enter model: L-1011 Enter year built: 1992 Enter flight hours: 85300 Enter maximum Passenger count: 160 New airplane : ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 addNewAirplane: Size of fleet =2 Enter command (or 'h' for help): p Current fleet contains 2 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 Enter command (or 'h' for help): a Enter type of airplane ( c= cargo, p= passenger): p Enter name of manufacturer: Airbus Enter model: A-350 Enter year built: 2004 Enter flight hours: 53200 Enter maximum Passenger count: 205 New airplane : ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53200, max passengers: 205 addNewAirplane: Size of fleet =3 Enter command (or 'h' for help): p Sample Interactive Session Current fleet contains 3 airplane(s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53200, max passengers: 205 Enter command (or 'h' for help): a Enter type of airplane ( c= cargo, p= passenger): c Enter name of manufacturer: Boeing Enter model: B777-200F Enter year built: 2008 Enter flight hours: 44607 Enter maximum cargo weight: 225000 New airplane : ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 addNewAirplane: Size of fleet =4 Enter command (or 'h' for help): p Current fleet contains 4 airplane(s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53200, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 Enter command (or 'h' for help): a Enter type of airplane (c = cargo, p= passenger) : p Enter name of manufacturer: Cessna Enter model: C-185 Enter year built: 2003 Enter flight hours: 8500 Enter maximum Passenger count: 6 New airplane : ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8500, max passengers: 6 addNewAirplane: Size of fleet =5 Enter command (or 'h' for help): p Current fleet contains 5 airplane(s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53200, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 Sample Interactive Session ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8500, max passengers: 6 Enter command (or 'h' for help): f Which airplane do you want to fly? 3 Length of flight (hours)? 34 Choosing airplane: ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53200, max passengers: 205 Flight complete: ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 Enter command (or 'h' for help): p Current fleet contains 5 airplane (s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8500, max passengers: 6 Enter command (or 'h' for help): f Which airplane do you want to fly? 8 Length of flight (hours)? 18 Airplane 8 not found. Enter command (or 'h' for help): f Which airplane do you want to fly? 2 Length of flight (hours)? 100 Choosing airplane: ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85300, max passengers: 160 Flight complete: ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160 Enter command (or 'h' for help): p Current fleet contains 5 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 ID\# : 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8500, max passengers: 6 Enter command (or 'h' for help): f Which airplane do you want to fly? 1 Length of flight (hours)? 7 Sample Interactive Session Choosing airplane: ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73200, max cargo: 102500 Flight complete: ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 Enter command (or 'h' for help): p Current fleet contains 5 airplane(s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8500, max passengers: 6 Enter command (or 'h' for help): f Which airplane do you want to fly? 5 Length of flight (hours) ? 4 Choosing airplane: ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8500, max passengers: 6 Flight complete: ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Enter command (or 'h' for help): p Current fleet contains 5 airplane(s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Enter command (or 'h' for help): r Which airplane do you want to remove? 6 Airplane 6 not found. Enter command (or 'h' for help): p Current fleet contains 5 airplane(s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Sample Interactive Session Enter command (or 'h' for help): r Which airplane do you want to remove? 2 Choosing airplane: ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160 Destructor for PassengerPlane 2 Destructor for Airplane 2 Removal complete: Airplane [ID\#: 2, manufacturer: Lockeed, model: L-1011, year: 1992, hours: 85400, max passengers: 160] has been removed. Enter command (or 'h' for help): p Current fleet contains 4 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Enter command (or 'h' for help): f Which airplane do you want to fly? 2 Length of flight (hours) ? 8 Airplane 2 not found. Enter command (or 'h' for help): f Which airplane do you want to fly? 3 Length of flight (hours)? 12 Choosing airplane: ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53234, max passengers: 205 Flight complete: ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 Enter command (or 'h' for help): p Current fleet contains 4 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Enter command (or 'h' for help): a Enter type of airplane ( c= cargo, p= passenger): p Enter name of manufacturer: Boeing Enter model: B757-200 Enter year built: 2009 Enter flight hours: 35200 Enter maximum Passenger count: 185 Sample Interactive Session New airplane : ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35200, max passengers: 185 addNewAirplane: Size of fleet =5 Enter command (or 'h' for help): p Current fleet contains 5 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35200, max passengers: 185 Enter command (or 'h' for help): f Which airplane do you want to fly? 6 Length of flight (hours)? 16 Choosing airplane: ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35200, max passengers: 185 Flight complete: ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185 Enter command (or 'h' for help): p Current fleet contains 5 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185 Enter command (or 'h' for help): f Which airplane do you want to fly? 0 Length of flight (hours)? 10 Airplane 0 not found. Enter command (or 'h' for help): p Current fleet contains 5 airplane(s): ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\# : 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Sample Interactive Session ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185 Enter command (or 'h' for help): a Enter type of airplane ( c= cargo, p= passenger): C Enter name of manufacturer: Airbus Enter model: A-360 Enter year built: 2007 Enter flight hours: 38500 Enter maximum cargo weight: 300000 New airplane : ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38500, max cargo: 300000 addNewAirplane: Size of fleet =6 Enter command (or 'h' for help): p Current fleet contains 6 airplane (s) : ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185 ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38500, max cargo: 300000 Enter command (or 'h' for help): r Which airplane do you want to remove? 1 Choosing airplane: ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500 Destructor for CargoPlane 1 Destructor for Airplane 1 Removal complete: Airplane [ID\#: 1, manufacturer: Boeing, model: B747-400F, year: 1996, hours: 73207, max cargo: 102500] has been removed. Enter command (or 'h' for help): p Current fleet contains 5 airplane(s): ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185 ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38500, max cargo: 300000 Enter command (or 'h' for help): r Which airplane do you want to remove? 6 Sample Interactive Session Choosing airplane: ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185 Destructor for PassengerPlane 6 Destructor for Airplane 6 Removal complete: Airplane [ID\#: 6, manufacturer: Boeing, model: B757-200, year: 2009, hours: 35216, max passengers: 185] has been removed. Enter command (or 'h' for help): p Current fleet contains 4 airplane(s) : ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38500, max cargo: 300000 Enter command (or 'h' for help): f Which airplane do you want to fly? 1 Length of flight (hours)? 7 Airplane 1 not found. Enter command (or 'h' for help): f Which airplane do you want to fly? 7 Length of flight (hours)? 9 Choosing airplane: ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38500, max cargo: 300000 Flight complete: ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38509, max cargo: 300000 Enter command (or 'h' for help): p Current fleet contains 4 airplane (s): ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38509, max cargo: 300000 Enter command (or 'h' for help): c Invalid command: c Enter command (or 'h' for help): f Which airplane do you want to fly? 5 Length of flight (hours) ? 10 Choosing airplane: ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8504, max passengers: 6 Flight complete: ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8514, max passengers: 6 Enter command (or 'h' for help): p Current fleet contains 4 airplane(s) : Sample Interactive Session ID\#: 3, manufacturer: Airbus, model: A-350, year: 2004, hours: 53246, max passengers: 205 ID\#: 4, manufacturer: Boeing, model: B777-200F, year: 2008, hours: 44607, max cargo: 225000 ID\#: 5, manufacturer: Cessna, model: C-185, year: 2003, hours: 8514, max passengers: 6 ID\#: 7, manufacturer: Airbus, model: A-360, year: 2007, hours: 38509, max cargo: 300000 Enter command (or 'h' for help): q Are you sure that you want to exit the program? y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
