Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class vehicle {
- int price;
- int speed;
- int year;
- string name;
- public:
- int getPrice() { return price; };
- int getSpeed() { return speed; };
- int getYear() { return year; };
- string getname() { return name; };
- void setPrice(int price) { this->price = price; };
- void setSpeed(int speed) { this->speed = speed; };
- void setYear(int year) { this->year = year; };
- void setName(string name) { this->name = name; };
- };
- class Plane : public vehicle {
- public:
- int passengers;
- };
- class Car : public vehicle {
- public:
- int engine_size;
- };
- class Ship : public vehicle {
- public:
- int floors;
- };
- Plane pl;
- pl.setPrice(30000);
- pl.setSpeed(480);
- pl.setYear(2017);
- pl.setName("Boing");
- Car c;
- c.setPrice(15000);
- c.setSpeed(240);
- c.setYear(2020);
- c.setName("Tesla CyberTruck");
- Ship s;
- s.setPrice(20000);
- s.setSpeed(150);
- s.setYear(2015);
- s.setName("Aurora");
- cout << pl.getPrice() << "$" << endl;
- cout << pl.getSpeed() << "KM/H" << endl;
- cout << pl.getYear() << endl;
- cout << c.getname() << endl;
- cout << c.getPrice() << "$" << endl;
- cout << c.getSpeed() << "KM/H" << endl;
- cout << c.getYear() << endl;
- cout << s.getname() << endl;
- cout << s.getPrice() << "$" << endl;
- cout << s.getSpeed() << "KM/H" << endl;
- cout << s.getYear() << endl;
- cout << s.getname() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment