evcamels

lr-5-2(19)

Nov 18th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.74 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. class transport{
  6.     string species;
  7. public:
  8.     void set(string species){
  9.         this->species = species;
  10.     }
  11.     string get(){
  12.         return species;
  13.     }
  14. };
  15. class car : public transport{
  16.     string mark;
  17. public:
  18.     void set1(string mark){
  19.         this->mark = mark;
  20.     }
  21.     string car_mark(){
  22.         return mark;
  23.     }
  24. };
  25. class driver : public car{
  26.     string name;
  27.     int age, experience;
  28. public:
  29.     void set2(string name, int age, int experience){
  30.         this->name = name;
  31.         this->age = age;
  32.         this->experience = experience;
  33.     }
  34.     string _get0(){
  35.         return name;
  36.     }
  37.     int _get(){
  38.         return experience;
  39.     }
  40.     int _get1(){
  41.         return age;
  42.     }
  43. };
  44. class official_driver : public driver{
  45. public:
  46.     void exp(){
  47.         if(_get() < 10){
  48.             cout << "Не допускается к работе!" << endl;
  49.         }else cout << "Допужен до работы служебным водителем по стажу!" << endl;
  50.     }
  51.     void age(){
  52.         if(_get1() > 50 && _get1() < 18){
  53.             cout << "Не допускается к работе!" << endl;
  54.         }else cout << "Допущен до работы служебным водителем по возрасту!" << endl;
  55.     }
  56. };
  57. class taxi_driver : public driver{
  58. public:
  59.     void exp1(){
  60.         if(_get() < 3){
  61.             cout << "Не допускается к работе!" << endl;
  62.         }else cout << "Допущен для работы в такси по стажу!" << endl;
  63.     }
  64.     void age1(){
  65.         if(_get1() > 50 && _get1() < 18){
  66.             cout << "Не допускается к работе!" << endl;
  67.         }else cout << "Допущен для работы в такси по возрасту!" << endl;
  68.     }
  69. };
  70. int main(int argc, const char * argv[]) {
  71.     official_driver od;
  72.     od.set("Легковой автомобиль");
  73.     od.set1("Mercedes");
  74.     od.set2("Иванов Иван Иванович", 30, 10);
  75.     cout << od.get() << endl << od.car_mark() << endl;
  76.     cout << od._get0() << endl;
  77.     cout << "Возраст: " << od._get1() << endl;
  78.     cout << "Стаж вождения: " << od._get() << endl;
  79.     od.exp();
  80.     od.age();
  81.     cout << endl;
  82.    
  83.     taxi_driver td;
  84.     td.set("Мультивен");
  85.     td.set1("Volkswagen");
  86.     td.set2("Петров Денис Игоревич", 25, 5);
  87.     cout << td.get() << endl << td.car_mark() << endl;
  88.     cout << td._get0() << endl;
  89.     cout << "Возраст: " << td._get1() << endl;
  90.     cout << "Стаж вождения: " << td._get() << endl;
  91.     td.exp1();
  92.     td.age1();
  93.     cout << endl;
  94.     return 0;
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment