Im fairly new to c++ and need help with my assignment in school. Can anyone please show me how to program this?
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.
Write a function in the airplane class that will print out all of the airplaneās information, including printing out the information for the engines. Have main create an airplane and cause it to print its information.
well i havent exactly gotten very far. Im basically stuck towards the beginning. Ill post what I have, give me a few. Im using visual studio 2010 c++. Ill post my code and all here in a few.
string make;//private variable for make of plane
string model;//private variable for model of plane
string color;//private variable for color of plane
public:
void planeMake();//getter for make
void setplaneMake(string);//setter for make
void planeModel();//getter for model
void setplaneModel(string);//setter for model
void planeColor();//getter for color
void setplaneColor(string);};//setter for color
string rpm;//private variable for rpm of engine
string make;//private variable for make of engine
string model;//private variable for model of engine
string size;//private variable for size of engine
public:
void engineRpm();//getter for rpm
void setengineRpm(string);//setter for rpm
void engineMake();//getter for make
void setengineMake(string);//setter for make
void engine model();//getter for model
void set engineModel(string);//setter for model
void engineSize;//getter for size
void setengineSize(string);};//setter for size
voidint main(){main returns an int. Always and forever.
Anyway, you need to write the getter and setter functions. They're very simple. All they do is change the value of something in the class, or return the value of something in the class. I note that all your getter functions don't currently return anything. That needs to change.
Well then time to suck it up and fail the assignment. Perhaps your teacher will note that you're unable to do this and direct you back towards the basics of functions.
i figured it out with a little help, not as hard as I thought, I just wanted to see how someone would do the assignment thats not from my college and see what their background is like and how it compares to what we're being taught. One thing though is our teacher showed us many examples and wants us to use void on everything like I showed, and not int. Not sure why.