Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Vehicle {
- private:
- int fuel;
- int price;
- char color[20];
- char brand[20];
- public:
- void setFuel(int someFuel){
- fuel = someFuel;
- }
- void setPrice(int thePrice){
- price = thePrice;
- }
- void setColor(char theColor[]){
- strcpy(this->color, theColor );
- }
- void setBrand(char thebrand[]){
- strcpy(this->brand, thebrand);
- }
- int getFuel(){
- return fuel;
- }
- int getPrice(){
- return price;
- }
- char* getColor(){
- return color;
- }
- char* getBrand(){
- return brand;
- }
- };
- int main (int argc, char * const argv[]) {
- // insert code here...
- Vehicle car;
- Vehicle motorCycle;
- car.setFuel(70);
- motorCycle.setFuel(20);
- car.setPrice(1500000);
- motorCycle.setPrice(400000);
- car.setColor("Blue");
- motorCycle.setColor("Red");
- car.setBrand("Honda");
- motorCycle.setBrand("Yamaha");
- cout << "== Car Details == " << endl;
- cout << "Car MAX Fuel is " << car.getFuel() << endl;
- cout << "Car Price is RP." << car.getPrice() << endl;
- cout << "Car Color is " << car.getColor() << endl ;
- cout << "Car Brand is " << car.getBrand() << endl << endl;
- cout << "== MotorCycle Details == " << endl;
- cout << "MotorCycle MAX Fuel is " << motorCycle.getFuel() << endl;
- cout << "MotorCycle Price is RP." << motorCycle.getPrice() << endl;
- cout << "MotorCycle Color is " << motorCycle.getColor() << endl ;
- cout << "MotorCycle Brand is " << motorCycle.getBrand() << endl << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment