Advertisement
evcamels

lr-2_var-1

Nov 16th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class transport{
  4.     string name_transport;
  5. public:
  6.     void set(string name_transport){
  7.         this->name_transport = name_transport;
  8.     }
  9.     string name_tr(){
  10.         return name_transport;
  11.     }
  12. };
  13. class automobile: public transport{
  14.     string name_automobile;
  15. public:
  16.     void set1(string name_automobile){
  17.         this->name_automobile = name_automobile;
  18.     }
  19.     string name_auto(){
  20.         return name_automobile;
  21.     }
  22. };
  23. class driver : public automobile{
  24.     string name;
  25. public:
  26.     void set3(string name){
  27.         this->name = name;
  28.     }
  29.     string name_drivers(){
  30.         return name;
  31.     }
  32. };
  33. class drivers_taxi: public driver{
  34.     int cash;
  35. public:
  36.     void set4(int cash){
  37.         this->cash = cash;
  38.     }
  39.     int cash_taxi(){
  40.         return cash;
  41.     }
  42. };
  43. class official_driver: public driver{
  44.     int cash;
  45. public:
  46.     void set5(int cash){
  47.         this->cash = cash;
  48.     }
  49.     int cash_official(){
  50.         return cash;
  51.     }
  52. };
  53. class truck_driver: public driver{
  54.     int cash;
  55. public:
  56.     void set6(int cash){
  57.         this->cash = cash;
  58.     }
  59.     int cash_truck(){
  60.         return cash;
  61.     }
  62. };
  63.  
  64. int main() {
  65.     setlocale(LC_ALL, "rus");
  66.     official_driver worker1;
  67.     worker1.set("Легковой транспорт");
  68.     cout << worker1.name_tr() << endl;
  69.     worker1.set1("Тойота");
  70.     cout << worker1.name_auto() << endl;
  71.     worker1.set3("Иванов Михаил Дмитриевич");
  72.     cout << worker1.name_drivers() << endl;
  73.     worker1.set5(75000);
  74.     cout << worker1.cash_official() << endl;
  75.     cout << "-------------------------------" << endl;
  76.     drivers_taxi worker2;
  77.     worker2.set("Легковой транспорт");
  78.     cout << worker2.name_tr() << endl;
  79.     worker2.set1("Фольксваген");
  80.     cout << worker2.name_auto() << endl;
  81.     worker2.set3("Петров Руслан Дмитриевич");
  82.     cout << worker2.name_drivers() << endl;
  83.     worker2.set4(36500);
  84.     cout << worker2.cash_taxi() << endl;
  85.     cout << "-------------------------------" << endl;
  86.     truck_driver worker3;
  87.     worker3.set("Грузовой транспорт");
  88.     cout << worker3.name_tr() << endl;
  89.     worker3.set1("Камаз");
  90.     cout << worker3.name_auto() << endl;
  91.     worker3.set3("Смирнов Олег Вадимович");
  92.     cout << worker3.name_drivers() << endl;
  93.     worker3.set6(120000);
  94.     cout << worker3.cash_truck() << endl;
  95.     cout << "-------------------------------" << endl;
  96.    
  97.     return 0;
  98. }
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement