G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 8th, 2020 140 in 317 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. using namespace std;
  5. class Worker {
  6. public:
  7.     Worker(string _name, string _surname, string _transport, int _payment) :
  8.         name(_name), surname(_surname), transport(_transport), payment(_payment) {}
  9.     virtual void print() = 0;
  10.     virtual int calcPayment()=0;
  11. protected:
  12.     string name;
  13.     string surname;
  14.     int payment;
  15.     string transport;
  16. };
  17. class Employee :public Worker {
  18. public:
  19.     Employee(string name, string surname, string transport, int payment) :Worker(name, surname, transport, payment) {};
  20.  
  21.     void print() {
  22.         cout << setw(10) << name;
  23.         cout << setw(10) << surname;
  24.         cout << setw(10) << transport;
  25.         cout << setw(8) << payment << " руб." << endl;
  26.     };
  27.     int calcPayment() {
  28.         return payment;
  29.     };
  30. };
  31. class Temporary : public Worker {
  32. public:
  33.     Temporary(string _name, string _surname, string _transport, int _payment) :Worker(_name, _surname, _transport, _payment) {};
  34.     void print() {
  35.         cout << setw(10) << name;
  36.         cout << setw(10) << surname;
  37.         cout << setw(10) << transport;
  38.         cout << setw(8) << payment <<" руб."<< endl;
  39.     };
  40.     int calcPayment() {
  41.         return payment*=150;// ставка 150 рублей в час
  42.     };
  43. };
  44. int main()
  45. {
  46.     setlocale(LC_ALL, "Russian");
  47.     vector<Worker*> workers;
  48.     workers.push_back(new Employee("Иванов", "Иван", "Машина", 18000));// 18000 оклад
  49.     workers.push_back(new Temporary("Семенов", "Алексей", "Мотоцикл", 140));// 140 часов отработано
  50.     workers.push_back(new Employee("Смирнов", "Антон", "Машина", 15000));
  51.     workers.push_back(new Temporary("Антропов", "Кирилл", "Мотоцикл", 160));
  52.     workers.push_back(new Employee("Сидоркин", "Артем", "Машина", 25000));
  53.     workers.push_back(new Temporary("Петров", "Николай", "Мотоцикл", 210));
  54.     for (size_t i = 0; i < workers.size(); ++i)
  55.         workers[i]->calcPayment();
  56.     for (size_t i = 0; i < workers.size(); ++i)
  57.         workers[i]->print();
  58.  
  59.     workers.erase(workers.begin() + 2);
  60.     vector<Worker*>(workers).swap(workers);//если мы не собираемся расширять workers
  61.     workers.erase(workers.begin() + 3);
  62.     vector<Worker*>(workers).swap(workers);
  63.     /*
  64.     workers.erase(workers.begin() + 2);
  65.     workers.erase(workers.begin() + 3);
  66.     */
  67.     cout << endl;
  68.     for (size_t i = 0; i < workers.size(); ++i)
  69.         workers[i]->print();
  70. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top