View the step-by-step solution to:

cpp program that is used to schedule maintenance of the aircraft.

The assignment of Aircraft.cpp program that is used to schedule maintenance of the aircraft. for this assignment two types of aircrafts are used A380 and B737. A380 has 4 engines and its maintenance is due every 750 hours and B737 has two engines and its maintenance is due every 500 hours. the following class and the main program should not be modified and they should compile with Aircraft.cpp with no warnings and errors. An example of input is given below



A D-AIMB 550 400 370 600

B N470WN 410 350


output--

Aircraft: D-AIMB type: Airbus A380 has 4 engines


engine 1: 550 hours

engine 2: 400 hours

engine 3: 370 hours

engine 4: 600 hours


Maintenance schedule for D-AIMB

engine 1: maintenance due in 200 hours

engine 2: maintenance due in 350 hours

engine 3: maintenance due in 380 hours

engine 4: maintenance due in 150 hours


Aircraft: N470WN type: Boeing 737 has 2 engines

engine 1: 410 hours

engine 2: 350 hours

Maintenance schedule for N470WN

engine 1: maintenance due in 90 hours

engine 2: maintenance due in 150 hours


//

// Aircraft.h

//

#ifndef AIRCRAFT_H

#define AIRCRAFT_H

#include<string>


class Aircraft

{

 public:

  Aircraft(int n, std::string name_str);

  virtual const std::string type(void) const = 0;

  virtual const int maxHours(void) const = 0;

  const std::string name(void) const;

  int numEngines(void) const;

  void setHours(int i, int h);

  void print(void) const;

  void printSchedule(void) const;

  static Aircraft* makeAircraft(char ch, std::string name_str);

  virtual ~Aircraft(void);

 protected:

  const int numEng;

  const std::string nm;

  int* hrs;

};


class A380: public Aircraft

{

 public:

  A380(std::string name_str);

  virtual const std::string type(void) const;

  virtual const int maxHours(void) const;

};


class B737: public Aircraft

{

 public:

  B737(std::string name_str);

  virtual const std::string type(void) const;

  virtual const int maxHours(void) const;

};

#endif


//

// maintenance.cpp

//


#include "Aircraft.h"

#include <iostream>

using namespace std;


int main()

{

 char ch;

 string s;

 cin >> ch >> s;

 while ( cin )

 {

  Aircraft *p = Aircraft::makeAircraft(ch,s);

  if ( p != 0 )

  {

   for ( int i = 1; i <= p->numEngines(); i++ )

   {

    int h;

    cin >> h;

    p->setHours(i,h);

   }    


   p->print();

   p->printSchedule();

   cin >> ch >> s;

  }

  else

  {

   cout << "unknown aircraft code" << endl;

   return 1;

  }

 }

}

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question