Advertisement
evcamels

lr-1(2)

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