"Studying" is one of the most important parts of learning a new language. Whether that language is a human one or a computer one is irrelevant. I urge you to spend more time "studying" the syntax of classes and functions in the tutorials linked above. But once you have a grasp on the syntax, you should start with
class Bus {};
above your main function. Inside of this empty class you can write functions that "printing the document, bus full, add a passenger, set type, get type". These functions sound like they should be in the
public:
section of your Bus class. To give those functions the variables that they need, some of the variables declared in main will need to be moved to the Bus class, and they should be placed in the
private:
section. Your main code will need to have a new variable of type Bus. The Bus variable is what you use to call functions in the Bus class.
1 2
|
Bus bus;
<type> t = bus.getType(); //I don't know your assignment enought to know what <type> should be
|
get functions usually just have one line inside of them that returns a variable.
set functions usually just have one line that assigns a parameter that is passed to a variable.
One key thing you have to realize with classes is that variables in a class are shared between all the functions inside of that class. However, the variables in one Bus variable are not the same as another Bus variable.
Bus busCool, busFast; //busCool and busFast would not share the same variables, their variables are seperate