Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Fix the code below and do Not Modify. Need urgent Thanks a lot using namespace std; class Aircrew{ public: Aircrew(std::string name_str){ nm = name_str;

Please Fix the code below and do Not Modify. Need urgent Thanks a lot

using namespace std;

class Aircrew{

public:

Aircrew(std::string name_str){

nm = name_str;

}

virtual void scheduleFlight(int f, double h) const{}

static Aircrew *makeAircrew( char ch ,string name_str);

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

const std::string name(void) const{

return nm;

}

virtual const int maxFlights(void) const = 0;

const double maxHour(void) const{

int maxHour = 60;

double availableHour = maxHour - hoursWorked;

return availableHour;

}

void setFlights(int i){

flightsTaken = i;

}

void setHours(double h){

hoursWorked = h;

}

void print(void)const {

cout << type() << nm <<" has operated "<< flightsTaken << " flights for a total of ";

cout << hoursWorked << " hours this week"<< endl;

cout << "Available flights: " << maxFlights() << endl;

cout << "Available hours: " << maxHour() <

}

protected:

const string nm;

int flightsTaken;

int hoursWorked;

};

class Pilot: public Aircrew

{

public:

Pilot(string name_str):Aircrew(name_str){}

virtual const string type(void) const {

string name;

name = "Pilot: ";

return name;

}

virtual const int maxFlights(void) const{

int maxflights = 5;

int availableFlights = maxflights - flightsTaken;

return availableFlights;

}

virtual void scheduleFlight(int f, double h) const{

cout << "Attempting to schedule for " << f <<" stop(s) " ;

cout << h << " hours flight..." << endl;

}

};

Aircrew *Aircrew :: makeAircrew(char ch, string name_str){

if (ch == 'P')return new Pilot;

}

int main(){

Aircrew *obj2 = Aircrew:: makeAircrew( 'P',"Paul");

obj2->setHours(40);

obj2->setFlights(3);

obj2->print();

obj2->scheduleFlight(0,10);

}

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What roles have these individuals played in your life?

Answered: 1 week ago