The regular maintenance of aircraft engines is critical to ensure the high level of safety of air travel. Maintenance activities are scheduled for each engine of an aircraft after specific periods of use, which depend on the aircraft and engine model. In this assignment, you are asked to write a program that determines the maintenance schedule of aircraft engines. The program must be able to process different types of aircrafts (having different numbers of engines), requiring maintenance at different intervals. In this assignment, we will only consider two types of aircraft: Airbus A380 (four engines, requiring maintenance every 750 hours) and Boeing 737 (two engines, requiring maintenance every 500 hours).

Description

The input of the program is read from standard input. Each input line consists of a description of an aircraft, including the model (encoded as one character), the aircraft name (or "tail code"), and the number of hours recorded since the last maintenance check for each of its engines. The number of hours of use may differ among the engines of a given aircraft due to the fact that not all engines are subjected to maintenance at the same time.

Assignment

Aircrafts are represented as instances of the classes A380 and B737 that are derived from a base class Aircraft. The main program maintenance.cpp is provided, together with the header file Aircraft.h . Another program testAircraft.cpp is provided that tests the functionality of the Aircraft derived classes. You should not modify these files. You will implement the base class Aircraft, and the derived classes A380 and B737 in the file Aircraft.cpp . You will create a Makefile that includes a target all, which builds the executables maintenance and testAircraft. The maintenance program reads a list of aircraft descriptions from standard input and prints a description of the aircraft and its maintenance schedule. See the example input files and corresponding output files for details. Note that if an engine's maintenance is past due, a special output message is printed instead of a time. If an unknown aircraft code is used, the program prints an error message and exits (see example files).

Example: the input line:

A VH-OQF 630 550 470 690

describes an Airbus A380 named VH-OQF whose four engines have 630, 550, 470 and 690 hours of use since their last maintenance. Given this input, the maintenance program will print the following output:

Aircraft: VH-OQF type: Airbus A380 has 4 engines
engine 1: 630 hours
engine 2: 550 hours
engine 3: 470 hours
engine 4: 690 hours
Maintenance schedule for VH-OQF
engine 1: maintenance due in 120 hours
engine 2: maintenance due in 200 hours
engine 3: maintenance due in 280 hours
engine 4: maintenance due in 60 hours

If the input contains multiple lines, the program should process them sequentially until the end of file is reached in input.

Specification of the Aircraft classes

The Aircraft base class is an abstract class from which the classes A380 and B737 are derived. The base constructor takes two arguments: the number of engines and the aircraft name. In addition, the following member functions must be defined:

virtual const std::string type(void) const
A pure virtual function returning a string (A380 or B737).

virtual const int maxHours(void) const
A pure virtual function returning the maximum duration of use of an engine before maintenance is due.

const std::string name(void) const
A member function returning the name of the aircraft.

int numEngines(void) const
A member function returning the number of engines of the aircraft.

void setHours(int i, int h)
A member function used to set the current number of hours of use for engine i .

void print(void) const
A member function that prints the description of the aircraft on standard output (see first part of the above example).

void printSchedule(void) const
A member function that prints the maintenance schedule of the aircraft on standard output (see above example).

static Aircraft* makeAircraft(char ch, std::string name_str)
A static factory function that creates an Aircraft object of the appropriate type (determined by the character ch) and returns a pointer to it. If ch is 'A', an A380 must be created. If ch is B, a B737 must be created.

All compilations should complete without warnings (use the -Wall option).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.