evcamels

laba_5-var_6

Dec 9th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class transport{
  4.     string transport;
  5. public:
  6.     void set(string transport){
  7.         this->transport = transport;
  8.     }
  9.     string transp(){
  10.         return transport;
  11.     }
  12. };
  13. class train : public transport{
  14.     int vagon;
  15. public:
  16.     void set1(int vagon){
  17.         this->vagon = vagon;
  18.     }
  19.     int vag(){
  20.         return vagon;
  21.     }
  22. };
  23. class driver : public train{
  24.     string name, gender;
  25.     int age;
  26. public:
  27.     void set2(string name, string gender){
  28.         this->name = name;
  29.         this->gender = gender;
  30.     }
  31.     void set22(int age){
  32.         this->age = age;
  33.     }
  34.     string nname(){
  35.         return name;
  36.     }
  37.     string gend(){
  38.         return gender;
  39.     }
  40.     int ag(){
  41.         return age;
  42.     }
  43. };
  44. class electr_driver : public driver{
  45.     int time, cash;
  46. public:
  47.     void set3(int time, int cash){
  48.         this->time = time;
  49.         this->cash = cash;
  50.     }
  51.     int money(){
  52.         return cash;
  53.     }
  54.     int tim(){
  55.         return time;
  56.     }
  57. };
  58. class long_driver : public driver{
  59.     int cash, time;
  60. public:
  61.     void set4(int time, int cash){
  62.         this->cash = cash;
  63.         this->time = time;
  64.     }
  65.     int mon1(){
  66.         return cash;
  67.     }
  68.     int time1(){
  69.         return time;
  70.     }
  71. };
  72.  
  73. int main() {
  74.     long_driver one;
  75.     one.set("Поезд дальнего следования");
  76.     cout << "Работник водит : " << one.transp() << endl;
  77.     one.set1(6);
  78.     cout << "В поезде " << one.vag() << " вагонов" << endl;
  79.     one.set2("Михайлов Даниил Игоревич", "Мужской");
  80.     one.set22(45);
  81.     cout << "ФИО: " << one.nname() << endl;
  82.     cout << "Пол: " << one.gend() << endl;
  83.     cout << "Возраст: " << one.ag() << endl;
  84.     one.set4(500, 75000);
  85.     cout << "Время работы в месяц: " << one.time1() << endl;
  86.     cout << "Зарплата: " << one.mon1() << endl;
  87.     cout << endl;
  88.  
  89.     long_driver two;
  90.     two.set("Поезд дальнего следования");
  91.     cout << "Работник водит : " << two.transp() << endl;
  92.     two.set1(12);
  93.     cout << "В поезде " << two.vag() << " вагонов" << endl;
  94.     two.set2("Иванов Сергей Дмитриевич", "Мужской");
  95.     two.set22(55);
  96.     cout << "ФИО: " << two.nname() << endl;
  97.     cout << "Пол: " << two.gend() << endl;
  98.     cout << "Возраст: " << two.ag() << endl;
  99.     two.set4(650, 130000);
  100.     cout << "Время работы в месяц: " << two.time1() << endl;
  101.     cout << "Зарплата: " << two.mon1() << endl;
  102.     cout << endl;
  103.    
  104.     electr_driver three;
  105.     three.set("Электричка");
  106.     cout << "Работник водит: " << three.transp() << endl;
  107.     three.set1(4);
  108.     cout << "В электричке " << three.vag() << " вагонов" << endl;
  109.     three.set2("Любимова Оксана Эдуардовна", "Женский");
  110.     three.set22(48);
  111.     cout << "ФИО: " << three.nname() << endl;
  112.     cout << "Пол: " << three.gend() << endl;
  113.     cout << "Возраст: " << three.ag() << endl;
  114.     three.set3(350, 60000);
  115.     cout << "Время работы в месяц " << three.tim() << endl;
  116.     cout << "Зарплата: " << three.money() << endl;
  117.     cout << endl;
  118.    
  119.     electr_driver four;
  120.     four.set("Электричка");
  121.     cout << "Работник водит: " << four.transp() << endl;
  122.     four.set1(7);
  123.     cout << "В электричке " << four.vag() << " вагонов" << endl;
  124.     four.set2("Денисов Максим Викторович", "Мужской");
  125.     four.set22(35);
  126.     cout << "ФИО: " << four.nname() << endl;
  127.     cout << "Пол: " << four.gend() << endl;
  128.     cout << "Возраст: " << four.ag() << endl;
  129.     four.set3(410, 90000);
  130.     cout << "Время работы в месяц " << four.tim() << endl;
  131.     cout << "Зарплата: " << four.money() << endl;
  132.     cout << endl;
  133.    
  134.    
  135.     return 0;
  136. }
  137.  
Add Comment
Please, Sign In to add comment