Advertisement
Derga

Untitled

Dec 3rd, 2023 (edited)
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 53.94 KB | None | 0 0
  1.  
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <string>
  5. #include <unordered_set>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. class Address {
  11.     string city_ = "";
  12.     string street_ = "";
  13.     size_t house_number_ = 0;
  14.     size_t building_ = 0;
  15.     size_t entrance_ = 0;
  16.     string doorphone_ = "";
  17.     size_t flat_ = 0;
  18.  
  19. public:
  20.     Address() {}
  21.     Address(const string& city, const string& street, size_t house_number,
  22.         size_t building, size_t entrance, string doorphone, size_t flat)
  23.         : city_(city)
  24.         , street_(street)
  25.         , house_number_(house_number)
  26.         , building_(building)
  27.         , entrance_(entrance)
  28.         , doorphone_(doorphone)
  29.         , flat_(flat)
  30.     {}
  31.  
  32.     Address(const Address& address) :
  33.         Address(address.city_, address.street_, address.house_number_,
  34.             address.building_, address.entrance_, address.doorphone_, address.flat_)
  35.     {}
  36.  
  37.     ~Address() {}
  38.  
  39.     Address operator=(const Address& address) {
  40.         if (&address != this) {
  41.             city_ = address.city_;
  42.             street_ = address.street_;
  43.             house_number_ = address.house_number_;
  44.             building_ = address.building_;
  45.             entrance_ = address.entrance_;
  46.             doorphone_ = address.doorphone_;
  47.             flat_ = address.flat_;
  48.         }
  49.         return *this;
  50.     }
  51.  
  52.     string GetCity() { return city_; }
  53.     string GetStreet() { return street_; }
  54.     size_t GetHouseNumber() { return house_number_; }
  55.     size_t GetBuilding() { return building_; }
  56.     size_t GetEntrance() { return entrance_; }
  57.     string GetDoorphone() { return doorphone_; }
  58.     size_t GetFlat() { return flat_; }
  59.  
  60.     void SetCity(const string& city) { city_ = city; }
  61.     void SetStreet(const string street) { street_ = street; }
  62.     void SetHouseNumber(size_t house_number) { house_number_ = house_number; }
  63.     void SetBuilding(size_t building) { building_ = building; }
  64.     void SetEntrance(size_t entrance) { entrance_ = entrance; }
  65.     void SetDoorphone(const string& doorphone) { doorphone_ = doorphone; }
  66.     void SetFlat(size_t flat) { flat_ = flat; }
  67.  
  68.     void Print() {
  69.         cout << "город " << GetCity() << ", улица " << GetStreet() << ", дом номер " << GetHouseNumber()
  70.             << ", корпус " << GetBuilding() << ", подъезд " << GetEntrance()
  71.             << ", квартира " << GetFlat() << ' ' << ", код домофона " << GetDoorphone() << '\n';
  72.     }
  73.     void Reset() {
  74.         city_ = "";
  75.         street_ = "";
  76.         house_number_ = 0;
  77.         building_ = 0;
  78.         entrance_ = 0;
  79.         doorphone_ = "";
  80.         flat_ = 0;
  81.     }
  82. };
  83.  
  84. class Date {
  85. private:
  86.     size_t year_;
  87.     size_t month_;
  88.     size_t day_;
  89.  
  90. public:
  91.     Date(size_t year, size_t month, size_t day) : year_(year), month_(month), day_(day) {};
  92.     Date(size_t month, size_t day) : Date(0, month, day) {};
  93.     Date(size_t day) : Date(0, 0, day) {}
  94.     Date() : Date(0, 0, 0) {}
  95.     Date(const Date& date) : Date(date.year_, date.month_, date.day_) {}
  96.     ~Date() {}
  97.  
  98.     Date& operator=(const Date& date) {
  99.         if (&date != this) {
  100.             year_ = date.year_;
  101.             month_ = date.month_;
  102.             day_ = date.day_;
  103.         }
  104.         return *this;
  105.     }
  106.  
  107.     size_t GetYear() const {
  108.         return year_;
  109.     }
  110.     size_t GetMonth() const {
  111.         return month_;
  112.     }
  113.     size_t GetDay() const {
  114.         return day_;
  115.     }
  116.     void SetYear(size_t year) {
  117.         year_ = year;
  118.     }
  119.     void SetMonth(size_t month) {
  120.         month_ = month;
  121.     }
  122.     void SetDay(size_t day) {
  123.         day_ = day;
  124.     }
  125.     void Print() {
  126.         cout << day_ << '.' << month_ << '.' << year_<< '\n';
  127.     }
  128. };
  129.  
  130. bool operator<(const Date& lhs, const Date& rhs) {
  131.     if (lhs.GetYear() != rhs.GetYear()) {
  132.         return lhs.GetYear() < rhs.GetYear();
  133.     }
  134.     if (lhs.GetMonth() != rhs.GetMonth()) {
  135.         return lhs.GetMonth() < rhs.GetMonth();
  136.     }
  137.     return lhs.GetDay() < rhs.GetDay();
  138. }
  139.  
  140. class Person {
  141. private:
  142.     string surname_ = "";
  143.     string name_ = "";
  144.     string patronymic_ = "";
  145.     bool is_male_ = false;
  146.     size_t age_ = 0;
  147.  
  148.     Date date_of_birth_;
  149.  
  150.     Address residence_;
  151.     Address registration_;
  152.  
  153. public:
  154.     Person(const string& surname, const string& name, const string& patronymic,
  155.         bool is_male, size_t age, const Date& date, const Address& residence, const Address& registration)
  156.         : surname_(surname)
  157.         , name_(name)
  158.         , patronymic_(patronymic)
  159.         , is_male_(is_male)
  160.         , age_(age)
  161.         , date_of_birth_(date)
  162.         , residence_(residence)
  163.         , registration_(registration)
  164.     {}
  165.  
  166.     Person() {}
  167.  
  168.     Person(const Person& person)
  169.         : Person(person.surname_, person.name_, person.patronymic_, person.is_male_,
  170.             person.age_, person.date_of_birth_,
  171.             person.residence_, person.registration_)
  172.     {}
  173.  
  174.     ~Person() {}
  175.  
  176.     Person& operator= (const Person& person) {
  177.         if (&person != this) {
  178.             surname_ = person.surname_;
  179.             name_ = person.name_;
  180.             patronymic_ = person.patronymic_;
  181.             is_male_ = person.is_male_;
  182.             age_ = person.age_;
  183.             date_of_birth_ = person.date_of_birth_;
  184.             residence_ = person.residence_;
  185.             registration_ = person.registration_;
  186.         }
  187.         return *this;
  188.     }
  189.  
  190.     void SetSurname(const string& surname) {
  191.         surname_ = surname;
  192.     }
  193.     void SetName(const string& name) {
  194.         name_ = name;
  195.     }
  196.     void SetPatronymic(const string& patrnomic) {
  197.         patronymic_ = patrnomic;
  198.     }
  199.     void SetIsMale(bool is_male) {
  200.         is_male_ = is_male;
  201.     }
  202.     void SetAge(size_t age) {
  203.         age_ = age;
  204.     }
  205.     void SetDateOfBirth(const Date& date) {
  206.         date_of_birth_ = date;
  207.     }
  208.     void SetResidenceAddress(const Address& address) {
  209.         residence_ = address;
  210.     }
  211.     void SetRegistrationAddress(const Address& address) {
  212.         registration_ = address;
  213.     }
  214.  
  215.     string GetSurname() const {
  216.         return surname_;
  217.     }
  218.     string GetName() const {
  219.         return name_;
  220.     }
  221.     string GetPatronymic() const {
  222.         return patronymic_;
  223.     }
  224.     bool GetIsMale() const {
  225.         return is_male_;
  226.     }
  227.     size_t GetAge() const {
  228.         return age_;
  229.     }
  230.     Date GetDateOfBirth() const {
  231.         return date_of_birth_;
  232.     }
  233.     Address GetResidenceAddress() const {
  234.         return residence_;
  235.     }
  236.     Address GetRegistrationAddress() const {
  237.         return registration_;
  238.     }
  239.  
  240.     void Print() const {
  241.         cout << GetSurname() << ' ' << GetName() << ' ' << GetPatronymic() << ' ';
  242.         if (is_male_) cout << "мужчина";
  243.         else cout << "женщина";
  244.  
  245.         cout << '\n' << GetAge() << " лет, родился ";
  246.         GetDateOfBirth().Print();
  247.         cout << "Адрес прохивания: ";
  248.         GetResidenceAddress().Print();
  249.         cout << "Адрес регистрации: ";
  250.         GetRegistrationAddress().Print();
  251.     }
  252. };
  253.  
  254. class Employee : virtual public Person {
  255.     Address address_;
  256.     string name_of_company_ = "";
  257.     bool got_job_ = false;
  258.  
  259. public:
  260.     Employee(const string& surname, const string& name, const string& patronymic,
  261.         bool is_male, size_t age, const Date& date, const Address& residence, const Address& registration,
  262.         Address& address, const string& name_of_company, bool got_job)
  263.         : Person(surname, name, patronymic, is_male, age, date, residence, registration)
  264.         , address_(address)
  265.         , name_of_company_(name_of_company)
  266.         , got_job_(got_job)
  267.     {}
  268.  
  269.     Employee(const Person& person, Address& address, const string& name_of_company, bool got_job)
  270.         : Person(person)
  271.         , address_(address)
  272.         , name_of_company_(name_of_company)
  273.         , got_job_(got_job)
  274.     {}
  275.    
  276.     Employee& operator= (const Employee& employee) {
  277.         if (&employee != this) {
  278.             SetSurname(employee.GetSurname());
  279.             SetName(employee.GetName());
  280.             SetPatronymic(employee.GetPatronymic());
  281.             SetIsMale(employee.GetIsMale());
  282.             SetAge(employee.GetAge());
  283.             SetDateOfBirth(employee.GetDateOfBirth());
  284.             SetResidenceAddress(employee.GetResidenceAddress());
  285.             SetRegistrationAddress(employee.GetRegistrationAddress());
  286.             address_ = employee.GetCompanyAddress();
  287.             name_of_company_ = employee.GetCompanyName();
  288.             got_job_ = employee.GetGotJob();
  289.         }
  290.         return *this;
  291.     }
  292.  
  293.     Employee() : Person() {}
  294.  
  295.     string GetCompanyName() const {
  296.         return name_of_company_;
  297.     }
  298.     Address GetCompanyAddress() const {
  299.         return address_;
  300.     }
  301.     bool GetGotJob() const {
  302.         return got_job_;
  303.     }
  304.  
  305.     void SetGotJob(bool got_job) {
  306.         got_job_ = got_job;
  307.         if (!got_job) ToQuitJob();
  308.     }
  309.     void SetCompanyName(const string& name_of_company) {
  310.         name_of_company_ = name_of_company;
  311.         SetGotJob(true);
  312.     }
  313.     void SetCompanyAddress(const Address& address) {
  314.         address_ = address;
  315.         SetGotJob(true);
  316.     }
  317.     void ToQuitJob() {
  318.         got_job_ = false;
  319.         name_of_company_ = "";
  320.         address_.Reset();
  321.     }
  322.  
  323.     void Print() {
  324.         Person::Print();
  325.         cout << '\n';
  326.         if (!GetGotJob()) {
  327.             cout << "Берзработный";
  328.             return;
  329.         }
  330.         cout << "работает в компании " << GetCompanyName() << '\n'
  331.             << "по сдресу:";
  332.         GetCompanyAddress().Print();
  333.     }
  334. };
  335.  
  336. class Worker : virtual public Person {
  337. private:
  338.     unordered_set<string> specialisations_;
  339. public:
  340.     Worker() {}
  341.     Worker(const Person& person, const unordered_set<string>& specializations)
  342.         : Person(person)
  343.         , specialisations_(specializations)
  344.     {}
  345.  
  346.     Worker(const Worker& worker)
  347.         : Person(worker.GetSurname(), worker.GetName(), worker.GetPatronymic(),
  348.             worker.GetIsMale(), worker.GetAge(), worker.GetDateOfBirth(),
  349.             worker.GetResidenceAddress(), worker.GetRegistrationAddress())
  350.         , specialisations_(worker.specialisations_)
  351.     {}
  352.  
  353.     ~Worker() {}
  354.     Worker operator=(const Worker& worker) {
  355.         if (&worker != this) {
  356.             SetSurname(worker.GetSurname());
  357.             SetName(worker.GetName());
  358.             SetPatronymic(worker.GetPatronymic());
  359.             SetIsMale(worker.GetIsMale());
  360.             SetAge(worker.GetAge());
  361.             SetDateOfBirth(worker.GetDateOfBirth());
  362.             SetResidenceAddress(worker.GetResidenceAddress());
  363.             SetRegistrationAddress(worker.GetRegistrationAddress());
  364.             specialisations_ = worker.specialisations_;
  365.         }
  366.         return *this;
  367.     }
  368.  
  369.     unordered_set<string> GetSpecializations() const { return specialisations_; }
  370.     void SetSpecialization(const unordered_set<string>& specializations) { specialisations_ = specializations; }
  371.     void PrintSpecializations() const {
  372.         for (auto& spec : specialisations_) {
  373.             cout << spec << ' ';
  374.         }
  375.     }
  376.     void AddSpecialization(const string& specialization) {
  377.         specialisations_.insert(specialization);
  378.     }
  379.     void DeleteSpecialization(const string& specialization) {
  380.         specialisations_.erase(specialization);
  381.     }
  382.     void ChangeSpecialization(const string& from, const string& to) {
  383.         DeleteSpecialization(from);
  384.         specialisations_.insert(to);
  385.     }
  386.     void Print() const {
  387.         Person::Print();
  388.         cout << "\nрабочий обладает следующими специальностями:\n";
  389.         for (auto spec : specialisations_) {
  390.             cout << spec << ' ';
  391.         }
  392.         cout << endl;
  393.     }
  394. };
  395.  
  396. class Engineer : virtual public Employee {
  397.     vector<Worker> workers_;
  398. public:
  399.     Engineer() {}
  400.     Engineer(const Employee& employee) {
  401.         SetSurname(employee.GetSurname());
  402.         SetName(employee.GetName());
  403.         SetPatronymic(employee.GetPatronymic());
  404.         SetIsMale(employee.GetIsMale());
  405.         SetAge(employee.GetAge());
  406.         SetDateOfBirth(employee.GetDateOfBirth());
  407.         SetResidenceAddress(employee.GetResidenceAddress());
  408.         SetRegistrationAddress(employee.GetRegistrationAddress());
  409.         SetCompanyAddress(employee.GetCompanyAddress());
  410.         SetCompanyName(employee.GetCompanyName());
  411.         SetGotJob(employee.GetGotJob());
  412.     }
  413.  
  414.     Engineer(const Engineer& engineer) {
  415.         SetSurname(engineer.GetSurname());
  416.         SetName(engineer.GetName());
  417.         SetPatronymic(engineer.GetPatronymic());
  418.         SetIsMale(engineer.GetIsMale());
  419.         SetAge(engineer.GetAge());
  420.         SetDateOfBirth(engineer.GetDateOfBirth());
  421.         SetResidenceAddress(engineer.GetResidenceAddress());
  422.         SetRegistrationAddress(engineer.GetRegistrationAddress());
  423.         SetCompanyAddress(engineer.GetCompanyAddress());
  424.         SetCompanyName(engineer.GetCompanyName());
  425.         SetGotJob(engineer.GetGotJob());
  426.         workers_ = engineer.workers_;
  427.     }
  428.  
  429.     ~Engineer() {}
  430.  
  431.     Engineer operator=(const Engineer& engineer) {
  432.         if (&engineer != this) {
  433.             SetSurname(engineer.GetSurname());
  434.             SetName(engineer.GetName());
  435.             SetPatronymic(engineer.GetPatronymic());
  436.             SetIsMale(engineer.GetIsMale());
  437.             SetAge(engineer.GetAge());
  438.             SetDateOfBirth(engineer.GetDateOfBirth());
  439.             SetResidenceAddress(engineer.GetResidenceAddress());
  440.             SetRegistrationAddress(engineer.GetRegistrationAddress());
  441.             SetCompanyAddress(engineer.GetCompanyAddress());
  442.             SetCompanyName(engineer.GetCompanyName());
  443.             SetGotJob(engineer.GetGotJob());
  444.             workers_ = engineer.workers_;
  445.         }
  446.         return *this;
  447.     }
  448.  
  449.     void AddWorker(const Worker& worker) {
  450.         workers_.push_back(worker);
  451.     }
  452.     void DismissWorker(const string& specialization) {
  453.         for (auto worker = workers_.begin(); worker != workers_.end(); ++worker) {
  454.             const auto& worker_specializations = worker->GetSpecializations();
  455.             if (worker_specializations.find(specialization) != worker_specializations.end()) {
  456.                 workers_.erase(worker);
  457.                 return;
  458.             }
  459.         }
  460.     }
  461.     void DismissAllWorkers() {
  462.         workers_.clear();
  463.     }
  464.     void PrintWorkers() {
  465.         for (const auto& worker : workers_) {
  466.             worker.PrintSpecializations();
  467.             cout << '\n';
  468.         }
  469.     }
  470.     void SortWorkersByBirthDate() {
  471.         sort(begin(workers_), end(workers_), [](const Worker& lhs, const Worker& rhs) {
  472.             return lhs.GetDateOfBirth() < rhs.GetDateOfBirth();
  473.         });
  474.     }
  475.     void PrintWorkersData() {
  476.         for (const auto worker : workers_) {
  477.             worker.Print();
  478.         }
  479.     }
  480.     void Print() {
  481.         Employee::Print();
  482.        
  483.         if (workers_.empty()) return;
  484.  
  485.         cout << "\nЗадачи данного инженера выполняют " << workers_.size() << " рабочих.\n"
  486.              << "Вот их данные : \n";
  487.         PrintWorkersData();
  488.     }
  489.     size_t GetWorkersCount() { return workers_.size(); }
  490.     vector<Worker> GetWorkers() const { return workers_; }
  491.     void SetWorkers(const vector<Worker> w) { workers_ = w; }
  492. };
  493.  
  494. class EngeineerWorker : public Engineer, public Worker {
  495. public:
  496.     EngeineerWorker() {}
  497.     ~EngeineerWorker() {}
  498.     EngeineerWorker(const Engineer& e, const Worker& w) : Engineer(e), Worker(w) {}
  499.    
  500.     EngeineerWorker& operator=(const EngeineerWorker& ew) {
  501.         if (&ew != this) {
  502.             SetSurname(ew.GetSurname());
  503.             SetName(ew.GetName());
  504.             SetPatronymic(ew.GetPatronymic());
  505.             SetIsMale(ew.GetIsMale());
  506.             SetAge(ew.GetAge());
  507.             SetDateOfBirth(ew.GetDateOfBirth());
  508.             SetResidenceAddress(ew.GetResidenceAddress());
  509.             SetRegistrationAddress(ew.GetRegistrationAddress());
  510.             SetCompanyAddress(ew.GetCompanyAddress());
  511.             SetCompanyName(ew.GetCompanyName());
  512.             SetGotJob(ew.GetGotJob());
  513.             SetWorkers(ew.GetWorkers());
  514.             SetSpecialization(ew.GetSpecializations());
  515.         }
  516.         return *this;
  517.     }
  518.  
  519.     void EWPrint() {
  520.         Engineer::Person::Print();
  521.         if (Worker::GetSpecializations().size() > 0) {
  522.             cout << "Как рабочий данный инженер-рабочий является:\n";
  523.             for (const auto& spec : Worker::GetSpecializations()) {
  524.                 cout << spec << ' ';
  525.             }
  526.         }
  527.         if (Engineer::GetWorkersCount()) {
  528.             cout << "\nВ команде данного инженера находятся следующие рабочие\n";
  529.             Engineer::PrintWorkersData();
  530.         }
  531.     }
  532. };
  533.  
  534. bool GetAndCheckString(string& str) {
  535.     if (!(cin >> str)) {
  536.         cout << "Введено неверное значение\n";
  537.         return false;
  538.     }
  539.     for (auto ch : str) {
  540.         if ('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z') continue;
  541.  
  542.         cout << "Введено неверное значение\n";
  543.         return false;
  544.     }
  545.  
  546.     return true;
  547. }
  548. bool GetAndCheckPositiveInteger(size_t& number) {
  549.     int64_t value;
  550.     if (!(cin >> value) || value < 0) {
  551.         cout << "Введено неверное значение\n";
  552.         return false;
  553.     }
  554.     number = static_cast<size_t>(value);
  555.     return true;
  556. }
  557. bool GetAndCheckStringDoorphone(string& doorphone) {
  558.     if (!(cin >> doorphone)) {
  559.         cout << "Введено неверное значение\n";
  560.         return false;
  561.     }
  562.     for (auto ch : doorphone) {
  563.         if ('0' <= ch && ch <= '9') continue;
  564.         if (ch == '#' || ch == '*') continue;
  565.  
  566.         cout << "Введено неверное значение\n";
  567.         return false;
  568.     }
  569.  
  570.     return true;
  571. }
  572. bool GetAddress(Address& address) {
  573.     string city, street, doorphone;
  574.     cout << "Введите город\n";
  575.     if (!GetAndCheckString(city)) {
  576.         return false;
  577.     }
  578.     cout << "Введите улицу\n";
  579.     if (!GetAndCheckString(street)) {
  580.         return false;
  581.     }
  582.     cout << "Введите домофон\n";
  583.     if (!GetAndCheckStringDoorphone(doorphone)) {
  584.         return false;
  585.     }
  586.  
  587.     size_t house, building, entrance, flat;
  588.     cout << "Введите номер дома\n";
  589.     if (!GetAndCheckPositiveInteger(house)) {
  590.         return false;
  591.     }
  592.     cout << "Введите корпус дома\n";
  593.     if (!GetAndCheckPositiveInteger(building)) {
  594.         return false;
  595.     }
  596.     cout << "Введите номер подъезда\n";
  597.     if (!GetAndCheckPositiveInteger(entrance)) {
  598.         return false;
  599.     }
  600.     cout << "Введите номер квартиры\n";
  601.     if (!GetAndCheckPositiveInteger(flat)) {
  602.         return false;
  603.     }
  604.  
  605.     address.SetCity(city);
  606.     address.SetStreet(street);
  607.     address.SetDoorphone(doorphone);
  608.     address.SetHouseNumber(house);
  609.     address.SetBuilding(building);
  610.     address.SetEntrance(entrance);
  611.     address.SetFlat(flat);
  612.  
  613.     return true;
  614. }
  615. bool GetDate(Date& date) {
  616.     size_t year, month, day;
  617.     cout << "Введите год рождения\n";
  618.     if (!GetAndCheckPositiveInteger(year)) {
  619.         return false;
  620.     }
  621.     if (year > 2023) {
  622.         cout << "Введено неверное значение\n";
  623.     }
  624.     cout << "Введите месяц рождения\n";
  625.     if (!GetAndCheckPositiveInteger(month)) {
  626.         return false;
  627.     }
  628.     if (month == 0 || month > 12) {
  629.         cout << "Введено неверное значение\n";
  630.     }
  631.     cout << "Введите день рождения\n";
  632.     if (!GetAndCheckPositiveInteger(day)) {
  633.         return false;
  634.     }
  635.     if (day == 0 || day > 31) {
  636.         cout << "Введено неверное значение\n";
  637.     }
  638.     Date new_date(year, month, day);
  639.     date = new_date;
  640.     return true;
  641. }
  642. bool GetPerson(Person& person) {
  643.     string surname, name, patronymic;
  644.     cout << "Введите фамилию:\n";
  645.     if (!GetAndCheckString(surname)) {
  646.         return false;
  647.     }
  648.     cout << "Введите имя:\n";
  649.     if (!GetAndCheckString(name)) {
  650.         return false;
  651.     }
  652.     cout << "Введите отчество:\n";
  653.     if (!GetAndCheckString(patronymic)) {
  654.         return false;
  655.     }
  656.  
  657.     bool is_male = false;
  658.     cout << "Введите пол: m/f\n";
  659.     char c;
  660.     cin >> c;
  661.     if (c == 'm') {
  662.         is_male = true;
  663.     }
  664.     else if (c == 'f') {}
  665.     else {
  666.         cout << "Введено неверное значение\n";
  667.         return false;
  668.     }
  669.  
  670.     size_t age;
  671.     cout << "Введите возраст:\n";
  672.     if (!GetAndCheckPositiveInteger(age)) {
  673.         return false;
  674.     }
  675.  
  676.     Date date_of_birth;
  677.     if (!GetDate(date_of_birth)) {
  678.         return false;
  679.     }
  680.     cout << "Введите адрес регистрации\n";
  681.     Address registration;
  682.     if (!GetAddress(registration)) {
  683.         return false;
  684.     }
  685.  
  686.     cout << "Введите адрес проживания\n";
  687.     Address residence;
  688.     if (!GetAddress(residence)) {
  689.         return false;
  690.     }
  691.  
  692.     person.SetSurname(surname);
  693.     person.SetName(name);
  694.     person.SetPatronymic(patronymic);
  695.     person.SetIsMale(is_male);
  696.     person.SetAge(age);
  697.     person.SetDateOfBirth(date_of_birth);
  698.     person.SetResidenceAddress(residence);
  699.     person.SetRegistrationAddress(registration);
  700.  
  701.     return true;
  702. }
  703. bool GetEmployee(Employee& employe) {
  704.     Person person;
  705.     if (!GetPerson(person)) {
  706.         return false;
  707.     }
  708.  
  709.     cout << "Введите адрес компании\n";
  710.     Address address;
  711.     if (!GetAddress(address)) {
  712.         return false;
  713.     }
  714.  
  715.     string name_of_company;
  716.     cout << "Введите название компании\n";
  717.     if (!GetAndCheckString(name_of_company)) {
  718.         return false;
  719.     }
  720.  
  721.     bool got_job = false;
  722.     cout << "Введите y/n, если в данный момент служащи имеет/не имеет работу\n";
  723.     char ch;
  724.     cin >> ch;
  725.     if (ch == 'y') {
  726.         got_job = true;
  727.     }
  728.     else if (ch == 'n') {
  729.         got_job = false;
  730.     }
  731.     else {
  732.         return false;
  733.     }
  734.  
  735.     Employee new_employe(person, address, name_of_company, got_job);
  736.     employe = new_employe;
  737.     return true;
  738. }
  739. bool GetWorker(Worker& worker) {
  740.     Person person;
  741.     if (!GetPerson(person)) return false;
  742.     size_t specialisations_count;
  743.     cout << "Введите количество специализаций рабочего\n";
  744.     if (!GetAndCheckPositiveInteger(specialisations_count)) {
  745.         return 0;
  746.     }
  747.     unordered_set<string> specializations;
  748.     for (size_t i = 0; i < specialisations_count; ++i) {
  749.         cout << "Введите специализацию рабочего\n";
  750.         string specialization;
  751.         cin >> specialization;
  752.         specializations.insert(specialization);
  753.     }
  754.     Worker new_worker(person, specializations);
  755.     worker = new_worker;
  756.     return true;
  757. }
  758. bool GetEngineer(Engineer& engineer) {
  759.     Employee employee;
  760.     if (!GetEmployee(employee)) return false;
  761.     Engineer new_engineer(employee);
  762.     engineer = new_engineer;
  763.     return true;
  764. }
  765. bool GetEngineerWorker(EngeineerWorker& engineer_worker) {
  766.     Engineer engineer;
  767.     if (!GetEngineer(engineer)) return false;
  768.  
  769.     cout << "Введите количество специализаций инженера-рабочего\n";
  770.     size_t specialisations_count = 0;
  771.     if (!GetAndCheckPositiveInteger(specialisations_count)) {
  772.         return 0;
  773.     }
  774.     unordered_set<string> specializations;
  775.     for (size_t i = 0; i < specialisations_count; ++i) {
  776.         cout << "Введите специализацию инженера-рабочего\n";
  777.         string specialization;
  778.         cin >> specialization;
  779.         specializations.insert(specialization);
  780.     }
  781.  
  782.     Worker worker;
  783.     EngeineerWorker ew(engineer, worker);
  784.     ew.SetSpecialization(specializations);
  785.     engineer_worker = ew;
  786.     return true;
  787. }
  788.  
  789. int main() {
  790.     setlocale(LC_ALL, "rus");
  791.     vector<Person> persons;
  792.     vector<Employee> employes;
  793.     vector<Worker> workers;
  794.     vector<Engineer> engineers;
  795.     vector<EngeineerWorker> engineers_workers;
  796.  
  797.     while (true) {
  798.         cout << R"(
  799. Данные вводятся на латинице.
  800. Нажмите:
  801. 1 - если хотите создать персону.
  802. 2 - если хотите создать служащего
  803. 3 - если хотите содать рабочего
  804. 4 - если хотите создать инженера
  805. 5 - если хотите создать инженера владеющего также навыками рабочего
  806. 6 - если хотите перейти к работе с созданными объектами
  807. )";
  808.         size_t value;
  809.         if (!GetAndCheckPositiveInteger(value)) {
  810.             return 0;
  811.         }
  812.        
  813.         if (value > 6) {
  814.             cout << "Введено неверное значение\n";
  815.             return 0;
  816.         }
  817.  
  818.         if (value == 6) {
  819.             break;
  820.         }
  821.        
  822.         if (value == 1) {
  823.             Person person;
  824.             if (!GetPerson(person)) {
  825.                 return 0;
  826.             }
  827.             persons.push_back(person);
  828.             continue;
  829.         }
  830.  
  831.         if (value == 2) {
  832.             Employee employe;
  833.             if (!GetEmployee(employe)) {
  834.                 return 0;
  835.             }
  836.  
  837.             employes.push_back(employe);
  838.             continue;
  839.         }
  840.  
  841.         if (value == 3) {
  842.             Worker worker;
  843.             if (!GetWorker(worker)) {
  844.                 return 0;
  845.             }
  846.             workers.push_back(worker);
  847.             continue;
  848.         }
  849.  
  850.         if (value == 4) {
  851.             Engineer engineer;
  852.             if (!GetEngineer(engineer)) {
  853.                 return 0;
  854.             }
  855.             engineers.push_back(engineer);
  856.             continue;
  857.         }
  858.  
  859.         if (value == 5) {
  860.             EngeineerWorker engineer_worker;
  861.             if (!GetEngineerWorker(engineer_worker)) {
  862.                 return 0;
  863.             }
  864.             engineers_workers.push_back(engineer_worker);
  865.             continue;
  866.         }
  867.  
  868.     }
  869.  
  870.     cout << "Вы создали \n"
  871.         << persons.size() << " - персон\n"
  872.         << employes.size() << " - служащих\n"
  873.         << workers.size() << " - рабочих\n"
  874.         << engineers.size() << " - инженеров\n"
  875.         << engineers_workers.size() << " - инженеров-рабочих\n";
  876.  
  877.     while (true) {
  878.         cout << R"(
  879. Вы можете воспользовать специальными функциями и свойствами объектов любого класса.
  880. Ведите значение соответствующее типу объякта
  881. 0 - персона
  882. 1 - служащий
  883. 2 - рабочий
  884. 3 - инженер
  885. 4 - инженер-рабочий
  886. 5 - выход
  887. )";
  888.  
  889.         size_t object_type;
  890.         if (!GetAndCheckPositiveInteger(object_type)) return 0;
  891.         if (object_type > 6) {
  892.             cout << "Введено неверное значение";
  893.             return 0;
  894.         }
  895.         if (object_type == 5) return 0;
  896.  
  897.         if (object_type == 0) {
  898.             cout << "У Вас есть " << persons.size() << " персон.\n";
  899.             if (persons.size() == 0) {
  900.                 cout << "Запустите программу заново и создате персону\n";
  901.                 return 0;
  902.             }
  903.             size_t idx = 0;
  904.             if (persons.size() > 1) {
  905.                 cout << "Введите значение - индекс, в диапазоне [0, " << persons.size()
  906.                     << "), с какой именно персоной Вы хотите поработать ? \n";
  907.                 if (!GetAndCheckPositiveInteger(idx)) return 0;
  908.                 if (idx >= persons.size()) {
  909.                     cout << "Введено неверное значени индекса\n";
  910.                     return 0;
  911.                 }
  912.             }
  913.             Person& person = persons[idx];
  914.             cout << "Данные персоны до выполненной операции\n";
  915.             person.Print();
  916.             cout << R"(
  917. Выберете номер операции, которую хотите собершить с персоной\n
  918. 0 - поменять фамилию
  919. 1 - поменять имя
  920. 2 - поменять отчество
  921. 3 - поменять пол
  922. 4 - поменять возраст
  923. 5 - поменять дату рождения
  924. 6 - поменять адрес проживания
  925. 7 - поменять адрес регистрации
  926. 8 - выйти
  927. )";
  928.             size_t operation_idx;
  929.             if (!GetAndCheckPositiveInteger(operation_idx)) return 0;
  930.  
  931.             if (operation_idx > 8) {
  932.                 cout << "Введен неверный код операции\n";
  933.             }
  934.             if (operation_idx == 8) return 0;
  935.  
  936.             if (operation_idx == 0) {
  937.                 string new_surname;
  938.                 if (!GetAndCheckString(new_surname)) return 0;
  939.                 person.SetSurname(new_surname);
  940.             }
  941.             if (operation_idx == 1) {
  942.                 string new_name;
  943.                 if (!GetAndCheckString(new_name)) return 0;
  944.                 person.SetName(new_name);
  945.             }
  946.             if (operation_idx == 2) {
  947.                 string new_patronymic;
  948.                 if (!GetAndCheckString(new_patronymic)) return 0;
  949.                 person.SetPatronymic(new_patronymic);
  950.             }
  951.             if (operation_idx == 3) {
  952.                 char c;
  953.                 cout << "Введите 0, если пол - мужской, иначе введите 1\n";
  954.                 cin >> c;
  955.                 if (c != '0' && c != '1') {
  956.                     cout << "Введено неверное значение\n";
  957.                     return 0;
  958.                 }
  959.                 person.SetIsMale(c == 0);
  960.             }
  961.             if (operation_idx == 4) {
  962.                 size_t new_age;
  963.                 if (!GetAndCheckPositiveInteger(new_age)) return 0;
  964.                 person.SetAge(new_age);
  965.             }
  966.             if (operation_idx == 5) {
  967.                 Date new_date;
  968.                 if (!GetDate(new_date)) return 0;
  969.                 person.SetDateOfBirth(new_date);
  970.             }
  971.             if (operation_idx == 6) {
  972.                 Address new_address;
  973.                 if (!GetAddress(new_address)) return 0;
  974.                 person.SetResidenceAddress(new_address);
  975.             }
  976.             if (operation_idx == 7) {
  977.                 Address new_address;
  978.                 if (!GetAddress(new_address)) return 0;
  979.                 person.SetRegistrationAddress(new_address);
  980.             }
  981.  
  982.             cout << "Данные персоны после выполненной операции\n";
  983.             person.Print();
  984.         }
  985.         if (object_type == 1) {
  986.             cout << "У Вас есть " << employes.size() << " служащих.\n";
  987.             if (employes.size() == 0) {
  988.                 cout << "Запустите программу заново и создате служащего\n";
  989.                 return 0;
  990.             }
  991.             size_t idx = 0;
  992.             if (employes.size() > 1) {
  993.                 cout << "Введите значение - индекс, в диапазоне [0, " << employes.size()
  994.                     << "), с каким именно служащим Вы хотите поработать ? \n";
  995.                 if (!GetAndCheckPositiveInteger(idx)) return 0;
  996.                 if (idx >= employes.size()) {
  997.                     cout << "Введено неверное значени индекса\n";
  998.                     return 0;
  999.                 }
  1000.             }
  1001.             Employee& employe = employes[idx];
  1002.             cout << "Данные персоны до выполненной операции\n";
  1003.             employe.Print();
  1004.             cout << R"(
  1005. Выберете номер операции, которую хотите собершить с персоной\n
  1006. 0 - поменять фамилию
  1007. 1 - поменять имя
  1008. 2 - поменять отчество
  1009. 3 - поменять пол
  1010. 4 - поменять возраст
  1011. 5 - поменять дату рождения
  1012. 6 - поменять адрес проживания
  1013. 7 - поменять адрес регистрации
  1014. 8 - уволиться
  1015. 9 - поменять название компании
  1016. 10 - поменять адрес компании
  1017. 11 - выйти
  1018. )";
  1019.             size_t operation_idx;
  1020.             if (!GetAndCheckPositiveInteger(operation_idx)) return 0;
  1021.  
  1022.             if (operation_idx > 11) {
  1023.                 cout << "Введен неверный код операции\n";
  1024.             }
  1025.             if (operation_idx == 11) return 0;
  1026.  
  1027.             if (operation_idx == 0) {
  1028.                 string new_surname;
  1029.                 if (!GetAndCheckString(new_surname)) return 0;
  1030.                 employe.SetSurname(new_surname);
  1031.             }
  1032.             if (operation_idx == 1) {
  1033.                 string new_name;
  1034.                 if (!GetAndCheckString(new_name)) return 0;
  1035.                 employe.SetName(new_name);
  1036.             }
  1037.             if (operation_idx == 2) {
  1038.                 string new_patronymic;
  1039.                 if (!GetAndCheckString(new_patronymic)) return 0;
  1040.                 employe.SetPatronymic(new_patronymic);
  1041.             }
  1042.             if (operation_idx == 3) {
  1043.                 char c;
  1044.                 cout << "Введите 0, если пол - мужской, иначе введите 1\n";
  1045.                 cin >> c;
  1046.                 if (c != '0' && c != '1') {
  1047.                     cout << "Введено неверное значение\n";
  1048.                     return 0;
  1049.                 }
  1050.                 employe.SetIsMale(c == 0);
  1051.             }
  1052.             if (operation_idx == 4) {
  1053.                 size_t new_age;
  1054.                 if (!GetAndCheckPositiveInteger(new_age)) return 0;
  1055.                 employe.SetAge(new_age);
  1056.             }
  1057.             if (operation_idx == 5) {
  1058.                 Date new_date;
  1059.                 if (!GetDate(new_date)) return 0;
  1060.                 employe.SetDateOfBirth(new_date);
  1061.             }
  1062.             if (operation_idx == 6) {
  1063.                 Address new_address;
  1064.                 if (!GetAddress(new_address)) return 0;
  1065.                 employe.SetResidenceAddress(new_address);
  1066.             }
  1067.             if (operation_idx == 7) {
  1068.                 Address new_address;
  1069.                 if (!GetAddress(new_address)) return 0;
  1070.                 employe.SetRegistrationAddress(new_address);
  1071.             }
  1072.             if (operation_idx == 8) {
  1073.                 employe.ToQuitJob();
  1074.             }
  1075.             if (operation_idx == 9) {
  1076.                 string new_company_name;
  1077.                 if (!GetAndCheckString(new_company_name)) return 0;
  1078.                 employe.SetCompanyName(new_company_name);
  1079.             }
  1080.             if (operation_idx == 10) {
  1081.                 Address new_address;
  1082.                 if (!GetAddress(new_address)) return 0;
  1083.                 employe.SetCompanyAddress(new_address);
  1084.             }
  1085.  
  1086.             cout << "Данные персоны после выполненной операции\n";
  1087.             employe.Print();
  1088.         }
  1089.         if (object_type == 2) {
  1090.             cout << "У Вас есть " << workers.size() << " рабочих.\n";
  1091.             if (workers.size() == 0) {
  1092.                 cout << "Запустите программу заново и создате рабочего\n";
  1093.                 return 0;
  1094.             }
  1095.             size_t idx = 0;
  1096.             if (workers.size() > 1) {
  1097.                 cout << "Введите значение - индекс, в диапазоне [0, " << workers.size()
  1098.                     << "), с каким именно рабочим Вы хотите поработать ? \n";
  1099.                 if (!GetAndCheckPositiveInteger(idx)) return 0;
  1100.                 if (idx >= workers.size()) {
  1101.                     cout << "Введено неверное значени индекса\n";
  1102.                     return 0;
  1103.                 }
  1104.             }
  1105.             Worker& worker = workers[idx];
  1106.             cout << "Данные персоны до выполненной операции\n";
  1107.             worker.Print();
  1108.             cout << R"(
  1109. Выберете номер операции, которую хотите собершить с персоной\n
  1110. 0 - поменять фамилию
  1111. 1 - поменять имя
  1112. 2 - поменять отчество
  1113. 3 - поменять пол
  1114. 4 - поменять возраст
  1115. 5 - поменять дату рождения
  1116. 6 - поменять адрес проживания
  1117. 7 - поменять адрес регистрации
  1118. 8 - задать специализации
  1119. 9 - добавить специализацию
  1120. 10 - удалить специализацию
  1121. 11 - сменить специализацию
  1122. 12 - выйти
  1123. )";
  1124.             size_t operation_idx;
  1125.             if (!GetAndCheckPositiveInteger(operation_idx)) return 0;
  1126.  
  1127.             if (operation_idx > 12) {
  1128.                 cout << "Введен неверный код операции\n";
  1129.             }
  1130.             if (operation_idx == 12) return 0;
  1131.  
  1132.             if (operation_idx == 0) {
  1133.                 string new_surname;
  1134.                 if (!GetAndCheckString(new_surname)) return 0;
  1135.                 worker.SetSurname(new_surname);
  1136.             }
  1137.             if (operation_idx == 1) {
  1138.                 string new_name;
  1139.                 if (!GetAndCheckString(new_name)) return 0;
  1140.                 worker.SetName(new_name);
  1141.             }
  1142.             if (operation_idx == 2) {
  1143.                 string new_patronymic;
  1144.                 if (!GetAndCheckString(new_patronymic)) return 0;
  1145.                 worker.SetPatronymic(new_patronymic);
  1146.             }
  1147.             if (operation_idx == 3) {
  1148.                 char c;
  1149.                 cout << "Введите 0, если пол - мужской, иначе введите 1\n";
  1150.                 cin >> c;
  1151.                 if (c != '0' && c != '!') {
  1152.                     cout << "Введено неверное значение\n";
  1153.                     return 0;
  1154.                 }
  1155.                 worker.SetIsMale(c == 0);
  1156.             }
  1157.             if (operation_idx == 4) {
  1158.                 size_t new_age;
  1159.                 if (!GetAndCheckPositiveInteger(new_age)) return 0;
  1160.                 worker.SetAge(new_age);
  1161.             }
  1162.             if (operation_idx == 5) {
  1163.                 Date new_date;
  1164.                 if (!GetDate(new_date)) return 0;
  1165.                 worker.SetDateOfBirth(new_date);
  1166.             }
  1167.             if (operation_idx == 6) {
  1168.                 Address new_address;
  1169.                 if (!GetAddress(new_address)) return 0;
  1170.                 worker.SetResidenceAddress(new_address);
  1171.             }
  1172.             if (operation_idx == 7) {
  1173.                 Address new_address;
  1174.                 if (!GetAddress(new_address)) return 0;
  1175.                 worker.SetRegistrationAddress(new_address);
  1176.             }
  1177.             if (operation_idx == 8) {
  1178.                 cout << "Сколько специализаций Вы планируете ввести?\n";
  1179.                 size_t sc;
  1180.                 if (!GetAndCheckPositiveInteger(sc)) {
  1181.                     return 0;
  1182.                 }
  1183.                 unordered_set<string> new_specs;
  1184.                 for (size_t i = 0; i < sc; ++i) {
  1185.                     string spec;
  1186.                     cin >> spec; //не проверяю цифры так специализации рабочих могут быть странными
  1187.                     new_specs.insert(spec);
  1188.                 }
  1189.                 worker.SetSpecialization(new_specs);
  1190.             }
  1191.             if (operation_idx == 9) {
  1192.                 string ns;
  1193.                 cin >> ns;
  1194.                 worker.AddSpecialization(ns);
  1195.             }
  1196.             if (operation_idx == 10) {
  1197.                 string spec;
  1198.                 cin >> spec;
  1199.                 worker.DeleteSpecialization(spec);
  1200.             }
  1201.             if (operation_idx == 11) {
  1202.                 string from, to;
  1203.                 cout << "Введите старую и новую специализации\n";
  1204.                 cin >> from >> to;
  1205.                 worker.ChangeSpecialization(from, to);
  1206.             }
  1207.  
  1208.             cout << "Данные рабочего после выполненной операции\n";
  1209.             worker.Print();
  1210.         }
  1211.         if (object_type == 3) {
  1212.             cout << "У Вас есть " << engineers.size() << " инженеров.\n";
  1213.             if (engineers.size() == 0) {
  1214.                 cout << "Запустите программу заново и создате инженера\n";
  1215.                 return 0;
  1216.             }
  1217.             size_t idx = 0;
  1218.             if (engineers.size() > 1) {
  1219.                 cout << "Введите значение - индекс, в диапазоне [0, " << engineers.size()
  1220.                     << "), с каким именно инженером Вы хотите поработать ? \n";
  1221.                 if (!GetAndCheckPositiveInteger(idx)) return 0;
  1222.                 if (idx >= engineers.size()) {
  1223.                     cout << "Введено неверное значени индекса\n";
  1224.                     return 0;
  1225.                 }
  1226.             }
  1227.             Engineer& engineer = engineers[idx];
  1228.             cout << "Данные персоны до выполненной операции\n";
  1229.             engineer.Print();
  1230.             cout << R"(
  1231. Выберете номер операции, которую хотите собершить с персоной\n
  1232. 0 - поменять фамилию
  1233. 1 - поменять имя
  1234. 2 - поменять отчество
  1235. 3 - поменять пол
  1236. 4 - поменять возраст
  1237. 5 - поменять дату рождения
  1238. 6 - поменять адрес проживания
  1239. 7 - поменять адрес регистрации
  1240. 8 - уволиться
  1241. 9 - поменять название компании
  1242. 10 - поменять адрес компании
  1243. 11 - добавить рабочего
  1244. 12 - уволить рабочего
  1245. 13 - уволить всех рабочих
  1246. 14 - вывести на экран специализации всех рабочих
  1247. 15 - вывести на экран все данные рабочих
  1248. 16 - отсортировать рабочих по дате рождения  
  1249. 17 - выйти
  1250. )";
  1251.             size_t operation_idx;
  1252.             if (!GetAndCheckPositiveInteger(operation_idx)) return 0;
  1253.  
  1254.             if (operation_idx > 17) {
  1255.                 cout << "Введен неверный код операции\n";
  1256.             }
  1257.             if (operation_idx == 17) return 0;
  1258.  
  1259.             if (operation_idx == 0) {
  1260.                 string new_surname;
  1261.                 if (!GetAndCheckString(new_surname)) return 0;
  1262.                 engineer.SetSurname(new_surname);
  1263.             }
  1264.             if (operation_idx == 1) {
  1265.                 string new_name;
  1266.                 if (!GetAndCheckString(new_name)) return 0;
  1267.                 engineer.SetName(new_name);
  1268.             }
  1269.             if (operation_idx == 2) {
  1270.                 string new_patronymic;
  1271.                 if (!GetAndCheckString(new_patronymic)) return 0;
  1272.                 engineer.SetPatronymic(new_patronymic);
  1273.             }
  1274.             if (operation_idx == 3) {
  1275.                 char c;
  1276.                 cout << "Введите 0, если пол - мужской, иначе введите 1\n";
  1277.                 cin >> c;
  1278.                 if (c != '0' && c != '!') {
  1279.                     cout << "Введено неверное значение\n";
  1280.                     return 0;
  1281.                 }
  1282.                 engineer.SetIsMale(c == 0);
  1283.             }
  1284.             if (operation_idx == 4) {
  1285.                 size_t new_age;
  1286.                 if (!GetAndCheckPositiveInteger(new_age)) return 0;
  1287.                 engineer.SetAge(new_age);
  1288.             }
  1289.             if (operation_idx == 5) {
  1290.                 Date new_date;
  1291.                 if (!GetDate(new_date)) return 0;
  1292.                 engineer.SetDateOfBirth(new_date);
  1293.             }
  1294.             if (operation_idx == 6) {
  1295.                 Address new_address;
  1296.                 if (!GetAddress(new_address)) return 0;
  1297.                 engineer.SetResidenceAddress(new_address);
  1298.             }
  1299.             if (operation_idx == 7) {
  1300.                 Address new_address;
  1301.                 if (!GetAddress(new_address)) return 0;
  1302.                 engineer.SetRegistrationAddress(new_address);
  1303.             }
  1304.             if (operation_idx == 8) {
  1305.                 engineer.ToQuitJob();
  1306.             }
  1307.             if (operation_idx == 9) {
  1308.                 string new_company_name;
  1309.                 if (!GetAndCheckString(new_company_name)) return 0;
  1310.                 engineer.SetCompanyName(new_company_name);
  1311.             }
  1312.             if (operation_idx == 10) {
  1313.                 Address new_address;
  1314.                 if (!GetAddress(new_address)) return 0;
  1315.                 engineer.SetCompanyAddress(new_address);
  1316.             }
  1317.             if (operation_idx == 11) {
  1318.                 Worker w;
  1319.                 if (!GetWorker(w)) return 0;
  1320.                 engineer.AddWorker(w);
  1321.             }
  1322.             if (operation_idx == 12) {
  1323.                 string spec;
  1324.                 cout << "Введите специальность рабочего, которого хотите удалить\n";
  1325.                 cin >> spec;
  1326.                 engineer.DismissWorker(spec);
  1327.             }
  1328.             if (operation_idx == 13) {
  1329.                 engineer.DismissAllWorkers();
  1330.             }
  1331.             if (operation_idx == 14) {
  1332.                 engineer.PrintWorkers();
  1333.             }
  1334.             if (operation_idx == 15) {
  1335.                 engineer.PrintWorkersData();
  1336.             }
  1337.             if (operation_idx == 16) {
  1338.                 engineer.SortWorkersByBirthDate();
  1339.             }
  1340.             cout << "Данные рабочего после выполненной операции\n";
  1341.             engineer.Print();
  1342.         }
  1343.         if (object_type == 4) {
  1344.             cout << "У Вас есть " << engineers_workers.size() << " инженеров-рабочих.\n";
  1345.             if (engineers_workers.size() == 0) {
  1346.                 cout << "Запустите программу заново и создате инженера-рабочего\n";
  1347.                 return 0;
  1348.             }
  1349.             size_t idx = 0;
  1350.             if (engineers_workers.size() > 1) {
  1351.                 cout << "Введите значение - индекс, в диапазоне [0, " << workers.size()
  1352.                     << "), с каким именно инженером-рабочим Вы хотите поработать ? \n";
  1353.                 if (!GetAndCheckPositiveInteger(idx)) return 0;
  1354.                 if (idx >= engineers_workers.size()) {
  1355.                     cout << "Введено неверное значени индекса\n";
  1356.                     return 0;
  1357.                 }
  1358.             }
  1359.             EngeineerWorker& ew = engineers_workers[idx];
  1360.             cout << "Данные инженера-рабочиего до выполненной операции\n";
  1361.             ew.EWPrint();
  1362.             cout << R"(
  1363. Выберете номер операции, которую хотите собершить с инженером-рабочим\n
  1364. 0 - поменять фамилию
  1365. 1 - поменять имя
  1366. 2 - поменять отчество
  1367. 3 - поменять пол
  1368. 4 - поменять возраст
  1369. 5 - поменять дату рождения
  1370. 6 - поменять адрес проживания
  1371. 7 - поменять адрес регистрации
  1372. 8 - уволиться
  1373. 9 - поменять название компании
  1374. 10 - поменять адрес компании
  1375. 11 - задать специализации
  1376. 12 - добавить специализацию
  1377. 13 - удалить специализацию
  1378. 14 - сменить специализацию
  1379. 15 - добавить рабочего
  1380. 16 - уволить рабочего
  1381. 17 - уволить всех рабочих
  1382. 18 - вывести на экран специализации всех рабочих
  1383. 19 - вывести на экран все данные рабочих
  1384. 20 - отсортировать рабочих по дате рождения  
  1385. 21 - выйти
  1386. )";
  1387.             size_t operation_idx;
  1388.             if (!GetAndCheckPositiveInteger(operation_idx)) return 0;
  1389.  
  1390.             if (operation_idx > 21) {
  1391.                 cout << "Введен неверный код операции\n";
  1392.             }
  1393.             if (operation_idx == 21) return 0;
  1394.  
  1395.             if (operation_idx == 0) {
  1396.                 string new_surname;
  1397.                 if (!GetAndCheckString(new_surname)) return 0;
  1398.                 ew.Person::SetSurname(new_surname);
  1399.             }
  1400.             if (operation_idx == 1) {
  1401.                 string new_name;
  1402.                 if (!GetAndCheckString(new_name)) return 0;
  1403.                 ew.Person::SetName(new_name);
  1404.             }
  1405.             if (operation_idx == 2) {
  1406.                 string new_patronymic;
  1407.                 if (!GetAndCheckString(new_patronymic)) return 0;
  1408.                 ew.Person::SetPatronymic(new_patronymic);
  1409.             }
  1410.             if (operation_idx == 3) {
  1411.                 char c;
  1412.                 cout << "Введите 0, если пол - мужской, иначе введите 1\n";
  1413.                 cin >> c;
  1414.                 if (c != '0' && c != '!') {
  1415.                     cout << "Введено неверное значение\n";
  1416.                     return 0;
  1417.                 }
  1418.                 ew.Person::SetIsMale(c == 0);
  1419.             }
  1420.             if (operation_idx == 4) {
  1421.                 size_t new_age;
  1422.                 if (!GetAndCheckPositiveInteger(new_age)) return 0;
  1423.                 ew.Person::SetAge(new_age);
  1424.             }
  1425.             if (operation_idx == 5) {
  1426.                 Date new_date;
  1427.                 if (!GetDate(new_date)) return 0;
  1428.                 ew.Person::SetDateOfBirth(new_date);
  1429.             }
  1430.             if (operation_idx == 6) {
  1431.                 Address new_address;
  1432.                 if (!GetAddress(new_address)) return 0;
  1433.                 ew.Person::SetResidenceAddress(new_address);
  1434.             }
  1435.             if (operation_idx == 7) {
  1436.                 Address new_address;
  1437.                 if (!GetAddress(new_address)) return 0;
  1438.                 ew.Person::SetRegistrationAddress(new_address);
  1439.             }
  1440.             if (operation_idx == 8) {
  1441.                 ew.ToQuitJob();
  1442.             }
  1443.             if (operation_idx == 9) {
  1444.                 string new_company_name;
  1445.                 if (!GetAndCheckString(new_company_name)) return 0;
  1446.                 ew.SetCompanyName(new_company_name);
  1447.             }
  1448.             if (operation_idx == 10) {
  1449.                 Address new_address;
  1450.                 if (!GetAddress(new_address)) return 0;
  1451.                 ew.SetCompanyAddress(new_address);
  1452.             }
  1453.             if (operation_idx == 11) {
  1454.                 cout << "Сколько специализаций Вы планируете ввести?\n";
  1455.                 size_t sc;
  1456.                 if (!GetAndCheckPositiveInteger(sc)) {
  1457.                     return 0;
  1458.                 }
  1459.                 unordered_set<string> new_specs;
  1460.                 for (size_t i = 0; i < sc; ++i) {
  1461.                     string spec;
  1462.                     cin >> spec; //не проверяю цифры так специализации рабочих могут быть странными
  1463.                     new_specs.insert(spec);
  1464.                 }
  1465.                 ew.SetSpecialization(new_specs);
  1466.             }
  1467.             if (operation_idx == 12) {
  1468.                 string ns;
  1469.                 cin >> ns;
  1470.                 ew.AddSpecialization(ns);
  1471.             }
  1472.             if (operation_idx == 13) {
  1473.                 string spec;
  1474.                 cin >> spec;
  1475.                 ew.DeleteSpecialization(spec);
  1476.             }
  1477.             if (operation_idx == 14) {
  1478.                 string from, to;
  1479.                 cout << "Введите старую и новую специализации\n";
  1480.                 cin >> from >> to;
  1481.                 ew.ChangeSpecialization(from, to);
  1482.             }
  1483.             if (operation_idx == 15) {
  1484.                 Worker w;
  1485.                 if (!GetWorker(w)) return 0;
  1486.                 ew.AddWorker(w);
  1487.             }
  1488.             if (operation_idx == 16) {
  1489.                 string spec;
  1490.                 cout << "Введите специальность рабочего, которого хотите удалить\n";
  1491.                 cin >> spec;
  1492.                 ew.DismissWorker(spec);
  1493.             }
  1494.             if (operation_idx == 17) {
  1495.                 ew.DismissAllWorkers();
  1496.             }
  1497.             if (operation_idx == 18) {
  1498.                 ew.PrintWorkers();
  1499.             }
  1500.             if (operation_idx == 19) {
  1501.                 ew.PrintWorkersData();
  1502.             }
  1503.             if (operation_idx == 20) {
  1504.                 ew.SortWorkersByBirthDate();
  1505.             }
  1506.             cout << "Данные рабочего после выполненной операции\n";
  1507.             ew.EWPrint();
  1508.         }
  1509.  
  1510.     }
  1511.  
  1512.     return 0;
  1513. }
  1514.  
  1515. /*
  1516. 5
  1517. a
  1518. a
  1519. a
  1520. m
  1521. 2
  1522. 2
  1523. 2
  1524. 2
  1525.  
  1526. a
  1527. a
  1528. 2
  1529. 2
  1530. 2
  1531. 2
  1532. 2
  1533. s
  1534. s
  1535. 2
  1536. 2
  1537. 2
  1538. 2
  1539. 2
  1540. a
  1541. a
  1542. 2
  1543. 2
  1544. 2
  1545. 2
  1546. 2
  1547. sdsad
  1548. y
  1549. 6
  1550. 3
  1551.  
  1552.  
  1553. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement