Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //служащий персона рабочий инженер
- //методы свойства конструкторы и декструкторы
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <unordered_set>
- #include <vector>
- using namespace std;
- class Address {
- string city_ = "";
- string street_ = "";
- size_t house_number_ = 0;
- size_t building_ = 0;
- size_t entrance_ = 0;
- string doorphone_ = "";
- size_t flat_ = 0;
- public:
- Address() {}
- Address(const string& city, const string& street, size_t house_number,
- size_t building, size_t entrance, string doorphone, size_t flat)
- : city_(city)
- , street_(street)
- , house_number_(house_number)
- , building_(building)
- , entrance_(entrance)
- , doorphone_(doorphone)
- , flat_(flat)
- {}
- Address(const Address& address) :
- Address(address.city_, address.street_, address.house_number_,
- address.building_, address.entrance_, address.doorphone_, address.flat_)
- {}
- ~Address() {}
- Address operator=(const Address& address) {
- return Address(address);
- }
- string GetCity() { return city_; }
- string GetStreet() { return street_; }
- size_t GetGouseNumber() { return house_number_; }
- size_t GetBuilding() { return building_; }
- size_t GetEntrance() { return entrance_; }
- string GetDoorphone() { return doorphone_; }
- size_t GetFlat() { return flat_; }
- void SetCity(const string& city) { city_ = city; }
- void SetStreet(const string street) { street_ = street; }
- void SetGouseNumber(size_t house_number) { house_number_ = house_number; }
- void SetBuilding(size_t building) { building_ = building; }
- void SetEntrance(size_t entrance) { entrance_ = entrance; }
- void SetDoorphone(const string& doorphone) { doorphone_ = doorphone; }
- void SetFlat(size_t flat) { flat_ = flat; }
- void Reset() {
- city_ = "";
- street_ = "";
- house_number_ = 0;
- building_ = 0;
- entrance_ = 0;
- doorphone_ = "";
- flat_ = 0;
- }
- };
- class Date {
- private:
- size_t year_;
- size_t month_;
- size_t day_;
- public:
- Date(size_t year, size_t month, size_t day) : year_(year), month_(month), day_(day) {};
- Date(size_t month, size_t day) : Date(0, month, day) {};
- Date(size_t day) : Date(0, 0, day) {}
- Date() : Date(0, 0, 0) {}
- Date(const Date& date) : Date(date.year_, date.month_, date.day_) {}
- ~Date() {}
- Date operator=(const Date& date) {
- return Date(date.year_, date.month_, date.day_);
- }
- size_t GetYear() const {
- return year_;
- }
- size_t GetMonth() const {
- return month_;
- }
- size_t GetDay() const {
- return day_;
- }
- void SetYear(size_t year) {
- year_ = year;
- }
- void SetMonth(size_t month) {
- month_ = month;
- }
- void SetDay(size_t day) {
- day_ = day;
- }
- };
- bool operator<(const Date& lhs, const Date& rhs) {
- if (lhs.GetYear() != rhs.GetYear()) {
- return lhs.GetYear() < rhs.GetYear();
- }
- if (lhs.GetMonth() != rhs.GetMonth()) {
- return lhs.GetMonth() < rhs.GetMonth();
- }
- return lhs.GetDay() < rhs.GetDay();
- }
- class Person {
- private:
- string surname_ = "";
- string name_ = "";
- string patronymic_ = "";
- bool is_male_ = false;
- size_t age_ = 0;
- Date date_of_birth_;
- Address residence_;
- Address registration_;
- public:
- Person(const string& surname, const string& name, const string& patronymic,
- bool is_male, size_t age, const Date& date, const Address& residence, const Address& registration)
- : surname_(surname)
- , name_(name)
- , patronymic_(patronymic)
- , is_male_(is_male)
- , age_(age)
- , date_of_birth_(date)
- , residence_(residence)
- , registration_(registration)
- {}
- Person(const string& surname, const string& name, const string& patronymic,
- bool is_male, size_t age, const Date& date, const Address& residence)
- : surname_(surname)
- , name_(name)
- , patronymic_(patronymic)
- , is_male_(is_male)
- , age_(age)
- , date_of_birth_(date)
- , residence_(residence)
- {}
- Person(const string& surname, const string& name, const string& patronymic,
- bool is_male, size_t age, const Date& date)
- : surname_(surname)
- , name_(name)
- , patronymic_(patronymic)
- , is_male_(is_male)
- , age_(age)
- , date_of_birth_(date)
- {}
- Person(const string& surname, const string& name, const string& patronymic,
- bool is_male, size_t age)
- : surname_(surname)
- , name_(name)
- , patronymic_(patronymic)
- , is_male_(is_male)
- , age_(age)
- {}
- Person(const string& surname, const string& name, const string& patronymic,
- bool is_male)
- : surname_(surname)
- , name_(name)
- , patronymic_(patronymic)
- , is_male_(is_male)
- {}
- Person(const string& surname, const string& name, const string& patronymic)
- : surname_(surname)
- , name_(name)
- , patronymic_(patronymic)
- {}
- Person(const string& surname, const string& name)
- : surname_(surname)
- , name_(name)
- {}
- Person(const string& name)
- : name_(name)
- {}
- Person() {}
- Person(const Person& person)
- : Person(person.surname_, person.name_, person.patronymic_, person.is_male_,
- person.age_, person.date_of_birth_,
- person.residence_, person.registration_)
- {}
- ~Person() {}
- Person operator= (const Person & person){
- return Person(person);
- }
- void SetSurname(const string& surname) {
- surname_ = surname;
- }
- void SetName(const string& name) {
- name_ = name;
- }
- void SetPatronymic(const string& patrnomic) {
- patronymic_ = patrnomic;
- }
- void SetIsMale(bool is_male) {
- is_male_ = is_male;
- }
- void SetAge(size_t age) {
- age_ = age;
- }
- void SetDateOfBirth(const Date& date) {
- date_of_birth_ = date;
- }
- void SetResidenceAddress(const Address& address) {
- residence_ = address;
- }
- void SetRegistrationAddress(const Address& address) {
- registration_ = address;
- }
- string GetSurname() const {
- return surname_;
- }
- string GetName() const {
- return name_;
- }
- string GetPatronymic() const {
- return patronymic_;
- }
- bool GetIsMale() const {
- return is_male_;
- }
- size_t GetAge() const {
- return age_;
- }
- Date GetDateOfBirth() const {
- return date_of_birth_;
- }
- Address GetResidenceAddress() const {
- return residence_;
- }
- Address GetRegistrationAddress() const {
- return registration_;
- }
- };
- class Employee : public Person {
- Address address_;
- string name_of_company_ = "";
- bool got_job_ = false;
- public:
- Employee(const string& surname, const string& name, const string& patronymic,
- bool is_male, size_t age, const Date& date, const Address& residence, const Address& registration,
- Address& address, const string& name_of_company, bool got_job)
- : Person(surname, name, patronymic, is_male, age, date, residence, registration)
- , address_(address)
- , name_of_company_(name_of_company)
- , got_job_(got_job)
- {}
- Employee(Address& address, const string& name_of_company, bool got_job)
- : Person()
- , address_(address)
- , name_of_company_(name_of_company)
- , got_job_(got_job)
- {}
- Employee(Address& address, const string& name_of_company)
- : Person()
- , address_(address)
- , name_of_company_(name_of_company)
- {}
- Employee(const string& name_of_company)
- : Person()
- , name_of_company_(name_of_company)
- {}
- Employee() : Person() {}
- string GetCompanyName() const {
- return name_of_company_;
- }
- Address GetCompanyAddress() const {
- return address_;
- }
- bool GetGotJob() const {
- return got_job_;
- }
- void SetCompanyName(const string& name_of_company) {
- name_of_company_ = name_of_company;
- }
- void SetCompanyAddress(const Address& address) {
- address_ = address;
- }
- void SetGotJob(bool got_job) {
- got_job_ = got_job;
- }
- void ToQuitJob() {
- got_job_ = false;
- name_of_company_ = "";
- address_.Reset();
- }
- };
- class Worker : virtual public Person {
- private:
- unordered_set<string> specialisations_;
- public:
- unordered_set<string> GetSpecializations() { return specialisations_; }
- Worker(const unordered_set<string>& specializations) : specialisations_(specializations) {}
- Worker() {}
- Worker(const Worker& worker) : specialisations_(worker.specialisations_) {}
- ~Worker() {}
- Worker operator=(const Worker& worker) { return Worker(worker); }
- void SetSpecialization(const unordered_set<string>& specializations) { specialisations_ = specializations; }
- void PrintSpecializations() const {
- for (auto& spec : specialisations_) {
- cout << spec << ' ';
- }
- }
- void AddSpecialization(const string& specialization) {
- specialisations_.insert(specialization);
- }
- void DeleteSpecialization(const string& specialization) {
- specialisations_.erase(specialization);
- }
- void ChangeSpecialization(const string& from, const string& to) {
- DeleteSpecialization(from);
- specialisations_.insert(to);
- }
- };
- class Engineer : virtual public Employee {
- vector<Worker> workers_;
- public:
- //Engineer(const Engineer& engineer) {}
- //Engineer operator=(const Engineer& engineer) {}
- void AddWorker(const Worker& worker) {
- workers_.push_back(worker);
- }
- void DismissWorker(const string& specialization) {
- for (auto worker = workers_.begin(); worker != workers_.end(); ++worker) {
- const auto& worker_specializations = worker->GetSpecializations();
- if (worker_specializations.find(specialization) != worker_specializations.end()) {
- workers_.erase(worker);
- return;
- }
- }
- }
- void DismissAllWorkers() {
- workers_.clear();
- }
- void PrintWorkers() {
- for (const auto& worker : workers_) {
- worker.PrintSpecializations();
- cout << '\n';
- }
- }
- void SortWorkersByBirthDate() {
- sort(begin(workers_), end(workers_), [](const Worker& lhs, const Worker& rhs) {
- return lhs.GetDateOfBirth() < rhs.GetDateOfBirth();
- });
- }
- };
- class EngeneerWorker : public Engineer, public Worker {
- };
- int main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement