MasterGun

1`

Apr 18th, 2020
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class vehicle {
  5. int price;
  6. int speed;
  7. int year;
  8. string name;
  9. public:
  10. int getPrice() { return price; };
  11. int getSpeed() { return speed; };
  12. int getYear() { return year; };
  13. string getname() { return name; };
  14.  
  15. void setPrice(int price) { this->price = price; };
  16. void setSpeed(int speed) { this->speed = speed; };
  17. void setYear(int year) { this->year = year; };
  18. void setName(string name) { this->name = name; };
  19.  
  20. };
  21. class Plane : public vehicle {
  22. public:
  23. int passengers;
  24. };
  25. class Car : public vehicle {
  26. public:
  27. int engine_size;
  28. };
  29. class Ship : public vehicle {
  30. public:
  31. int floors;
  32. };
  33.  
  34. Plane pl;
  35. pl.setPrice(30000);
  36. pl.setSpeed(480);
  37. pl.setYear(2017);
  38. pl.setName("Boing");
  39. Car c;
  40. c.setPrice(15000);
  41. c.setSpeed(240);
  42. c.setYear(2020);
  43. c.setName("Tesla CyberTruck");
  44. Ship s;
  45. s.setPrice(20000);
  46. s.setSpeed(150);
  47. s.setYear(2015);
  48. s.setName("Aurora");
  49. cout << pl.getPrice() << "$" << endl;
  50. cout << pl.getSpeed() << "KM/H" << endl;
  51. cout << pl.getYear() << endl;
  52. cout << c.getname() << endl;
  53. cout << c.getPrice() << "$" << endl;
  54. cout << c.getSpeed() << "KM/H" << endl;
  55. cout << c.getYear() << endl;
  56. cout << s.getname() << endl;
  57. cout << s.getPrice() << "$" << endl;
  58. cout << s.getSpeed() << "KM/H" << endl;
  59. cout << s.getYear() << endl;
  60. cout << s.getname() << endl;
  61.  
  62. return 0;
  63. }
RAW Paste Data