Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The scheduling of aircrew members must follow strict regulations on how long each person may work in a given week. Each aircrew member can work

The scheduling of aircrew members must follow strict regulations on how long each person may work in a given week. Each aircrew member can work on varying number of flights and hours depending on their job responsibilities. In this assignment, you are asked to write a program that determines whether a crew member may be scheduled for a specific flight based on their current workload. The program must be able to process different types of crew members (having different limitation on number of flights and hours). In this assignment, we will only consider three types of crew members: Pilot (5 flights, 60 hours/week), Attendant (8 flights, 60 hours/week), and a Tagged Attendant (8 flights, 60 hours/week). A tagged attendant is working as a backup for other fulltime attendants on the fight and registers only half the hours, meaning on a flight that physically takes 7 hours, a tagged attendant will only register 3.5 hours of work, whereas an Attendant or a Pilot will register the full 7 hours of work. A flight having stops counts as multiple flights. For example, a flight having 2 stops counts as 3 flights.

Description

The input of the program is read from standard input. Each input line consists of a description of an aircrew member, including the job title (encoded as one character), the name, number of flights recorded so far this week, and the number of hours worked during this week. Followed by the flight information, namely number of stops, and then total length of flight in hours.

Assignment

Aircrew members are represented as instances of the classes Pilot, Attendant and TaggedAttendant derived from a base class Aircrew. The main program scheduling.cpp is provided, together with the header file Aircrew.h . Another program testAircrew.cpp is provided that tests the functionality of the Aircrew derived classes. You should not modify these files. You will implement the base class Aircrew, and the derived classes Pilot, Attendant and TaggedAttendant in the file Aircrew.cpp . You will create a Makefile that includes a target all, which builds the executables scheduling and testAircrew. The scheduling program reads a list of aircrew descriptions from standard input and prints a description of the aircrew and his/her availability. See the example input files and corresponding output files for details. Note that the last line of output should reflect whether the crew member can be assigned to the specific flight or not. If an unknown crew code is used, the program prints an error message and exits (see example files).

Example:

the input line: P Alex 3 20 1 20

header file here

#ifndef AIRCREW_H #define AIRCREW_H #include

class Aircrew { public: Aircrew(std::string name_str); virtual const std::string type(void) const = 0; virtual const int maxFlights(void) const = 0; const double maxHours(void) const; const std::string name(void) const; void setFlights(int i); void setHours(double h); void print(void) const; virtual void scheduleFlight(int f, double h) const; static Aircrew* makeAircrew(char ch, std::string name_str); virtual ~Aircrew(void); protected: const std::string nm; int flightsTaken; double hoursWorked; };

class Pilot: public Aircrew { public: Pilot(std::string name_str); virtual const std::string type(void) const; virtual const int maxFlights(void) const; };

class Attendant: public Aircrew { public: Attendant(std::string name_str); virtual const std::string type(void) const; virtual const int maxFlights(void) const; };

class TaggedAttendant: public Aircrew { public: TaggedAttendant(std::string name_str); virtual const std::string type(void) const; virtual const int maxFlights(void) const; virtual void scheduleFlight(int f, double h) const; };

scheduling.cpp here

#include "Aircrew.h" #include using namespace std;

int main() { char ch; string s; cin >> ch >> s; while (cin) { Aircrew *p = Aircrew::makeAircrew(ch,s); if (p != 0) { int f; double h; cin >> f >> h; p->setFlights(f); p->setHours(h); cin >> f >> h; p->print(); p->scheduleFlight(f, h); cin >> ch >> s; } else { cout << "unknown aircrew type" << endl; return 1; } } }

test file here

#include "Aircrew.h" #include using namespace std;

int main() { Aircrew *p1 = Aircrew::makeAircrew('P', "Paul"); p1->setFlights(4); p1->setHours(40); p1->print(); p1->scheduleFlight(0,10); //can work delete p1;

Aircrew *p2 = Aircrew::makeAircrew('A', "Allen"); p2->setFlights(6); p2->setHours(20); p2->print(); p2->scheduleFlight(2,15.2); //cannot work delete p2;

Aircrew *p3 = Aircrew::makeAircrew('T', "Tony"); p3->setFlights(2); p3->setHours(50); p3->print(); p3->scheduleFlight(0,16); // can work delete p3; }

I need the body file to run header file please!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Understand the role of internal marketing and communications.

Answered: 1 week ago