Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that models an airplane. 1) Write a class that represents th

ID: 3655192 • Letter: W

Question

Write a C++ program that models an airplane. 1) Write a class that represents the airplane itself. It should have make, model, and another variable of your choice. Make sure these variables are private. 2) Write getters and setters for all of these variables. Remember that a getter is just a function that returns the value of a data member, and a setter is a function that takes a parameter and stores that value in the data member. 3) Write a class that represents an airplane engine. It should have private data members for rpm, make and model (make and model of the engine are not the same as for the airplane), and one additional variable of your choice. 4) Write getters and setters for these variables as well. 5) The airplane class should have 2 data members that are instances of the engine class. 6) Write a function in the airplane class that will print out all of the airplane

Explanation / Answer

#include #include using namespace std; class apEngine{ int rpm; string make,model; int cylinder; public: //constructors apEngine(); apEngine(int,string,string,int); //mutators void setRpm(int); void setMake(string); void setModel(string); void setcylinder(int); //accessors int getRpm(); string getMake(); string getModel(); int getcylinder(); }; //constructors apEngine::apEngine(){ rpm=2300; make="Lycoming"; model="O435"; cylinder=6; } apEngine::apEngine(int Rpm,string Make,string Model,int Cylinder){ rpm=Rpm; make=Make; model=Model; cylinder=Cylinder; } //mutators void apEngine::setRpm(int Rpm){rpm=Rpm;} void apEngine::setMake(string Make){make=Make;} void apEngine::setModel(string Model){model=Model;} void apEngine::setcylinder(int Cylinder){cylinder=Cylinder;} //accessors int apEngine::getRpm(){return rpm;} string apEngine::getMake(){return make;} string apEngine::getModel(){return model;} int apEngine::getcylinder(){return cylinder;} class airplane{ private: string make, model; int age; apEngine a,b; public: //constructors airplane(); airplane(string,string,int); //mutators void setMake(string); void setModel(string); void setAge(int); void setEngineA(apEngine); void setEngineB(apEngine); //accessors string getMake(); string getModel(); int getAge(); //function void printInfo(); }; //constructors airplane::airplane(){ make="Mitsubishi"; model="MU300"; age=1; } airplane::airplane(string Make,string Model,int Age){ make=Make; model=Model; age=Age; } //mutators void airplane::setMake(string Make){make=Make;} void airplane::setModel(string Model){model=Model;} void airplane::setAge(int Age){age=Age;} void airplane::setEngineA(apEngine A){a=A;} void airplane::setEngineB(apEngine B){b=B;} //accessors string airplane::getMake(){return make;} string airplane::getModel(){return model;} int airplane::getAge(){return age;} //function void airplane::printInfo(){ cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote