Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include "Windows.h"
- using namespace std;
- class Employee
- {
- public:
- Employee() : name("dafault"), id(0) {}
- Employee(string name, int id) : name(name), id(id) {}
- ~Employee() {}
- string getName() { return name; }
- int getId() { return id; }
- void setName(string name) { this->name = name; }
- void setId(int id) { this->id = id; }
- void show() { cout << id << " > " + name + "." << endl; }
- void input()
- {
- cout << "Input name: "; cin >> name;
- cout << "Input id: "; cin >> id;
- }
- protected:
- string name;
- int id;
- };
- class Student
- {
- public:
- Student() : education("no"), degree("no") {}
- Student(string education, string degree) : education(education), degree(degree) {}
- string getEducation() { return education; }
- string getDegree() { return degree; }
- void setEducation(string education) { this->education = education; }
- void setDegree(string degree) { this->degree = degree; }
- void show() { cout << "Finished " + education + " as " + degree + "." << endl; }
- void input()
- {
- cout << "Input education: "; cin >> education;
- cout << "Input degree: "; cin >> degree;
- }
- protected:
- string education;
- string degree;
- };
- class Manager : private Employee, private Student
- {
- public:
- Manager() : Employee(), Student(), position("default"), fitnessTaxes(0) {}
- Manager(string name, int id, string education, string degree, string position, double fitnessTaxes) : Employee(name, id), Student(education, degree), position(position), fitnessTaxes(fitnessTaxes) {}
- ~Manager() {}
- string getEducation() { return Student::getEducation(); }
- string getDegree() { return Student::getDegree(); }
- string getName() { return Employee::getName(); }
- int getId() { return Employee::getId(); }
- string getPosition() { return position; }
- double getFitnessTaxes() { return fitnessTaxes; }
- void setEducation(string education) { Student::setEducation(education); }
- void setDegree(string degree) { Student::setDegree(degree); }
- void setName(string name) { Employee::setName(name); }
- void setId(int id) { Employee::setId(id); }
- void setPosition(string position) { this->position = position; }
- void setFitnessTaxes(double fitnessTaxes) { this->fitnessTaxes = fitnessTaxes; }
- void show()
- {
- Employee::show();
- Student::show();
- cout << "Is a " << position << ", pays for fitness " << fitnessTaxes << " dollars." << endl;
- }
- void input()
- {
- Employee::input();
- Student::input();
- cout << "Input position: "; cin >> position;
- cout << "Input fitness taxes: "; cin >> fitnessTaxes;
- }
- protected:
- string position;
- double fitnessTaxes;
- };
- class Scientist : private Employee, private Student
- {
- public:
- Scientist() : Employee(), Student(), amountOfArticles(0) {}
- Scientist(string name, int id, string education, string degree, int amountOfArticles) : Employee(name, id), Student(education, degree), amountOfArticles(amountOfArticles) {}
- ~Scientist() {}
- string getEducation() { return Student::getEducation(); }
- string getDegree() { return Student::getDegree(); }
- string getName() { return Employee::getName(); }
- int getId() { return Employee::getId(); }
- int getAmountOfArticles() { return amountOfArticles; }
- void setEducation(string education) { Student::setEducation(education); }
- void setDegree(string degree) { Student::setDegree(degree); }
- void setName(string name) { Employee::setName(name); }
- void setId(int id) { Employee::setId(id); }
- void setAmountOfArticles(int amountOfArticles) { this->amountOfArticles = amountOfArticles; }
- void show()
- {
- Employee::show();
- Student::show();
- cout << "Published " << amountOfArticles << " articles." << endl;
- }
- void input()
- {
- Employee::input();
- Student::input();
- cout << "Input amount of articles: "; cin >> amountOfArticles;
- }
- protected:
- int amountOfArticles;
- };
- class Worker : public Employee
- {
- public:
- Worker() : Employee() {}
- Worker(string name, int id) : Employee(name, id) {}
- ~Worker() {}
- void show() { Employee::show(); }
- void input() { Employee::input(); }
- };
- class Brigadier : public Worker
- {
- public:
- Brigadier() : Worker(), productionRate(0.0) {}
- Brigadier(string name, int id, int productionRate) : Worker(name, id), productionRate(productionRate) {}
- ~Brigadier() {}
- int getProductionRate() { return productionRate; }
- void setProductionRate(int productionRate) { this->productionRate = productionRate; }
- void show()
- {
- Worker::show();
- cout<< "Is a brigadier. His production rate is " << productionRate << "%" << endl;
- }
- void input()
- {
- Worker::input();
- cout << "Input production rate: "; cin >> productionRate;
- }
- protected:
- int productionRate;
- };
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- Employee * e = new Employee();
- e->input();
- e->show();
- puts("##################################");
- Manager * m = new Manager();
- m->input();
- m->show();
- puts("##################################");
- Scientist * s = new Scientist();
- s->input();
- s->show();
- puts("##################################");
- Worker * w = new Worker();
- w->input();
- w->show();
- puts("##################################");
- Brigadier * b = new Brigadier();
- b->input();
- b->show();
- puts("##################################");
- system("pause>nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement