Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Employee
  7. {
  8. public:
  9.     string name;
  10.     int age;
  11.     string department;
  12.     string position;
  13.  
  14.     Employee(string name, int age, string department, string position)
  15.     {
  16.         this->name = name;
  17.         this->age = age;
  18.         this->department = department;
  19.         this->position = position;
  20.     }
  21.     Employee() {}
  22. };
  23.  
  24. class Department
  25. {
  26. public:
  27.     static const int SIZE_STAFF = 3;
  28.     static const int SIZE_POSITIONS = 3;
  29.     string name;
  30.     Employee staff[SIZE_STAFF];
  31.     string positions[SIZE_POSITIONS];
  32.  
  33.     Department(){}
  34.     Department(string name, Employee employee[], string positions[])
  35.     {
  36.         this->name = name;
  37.         for (int i = 0; i < SIZE_STAFF; ++i) {
  38.             staff[i] = employee[i];
  39.         }
  40.         for (int i = 0; i < SIZE_POSITIONS; ++i) {
  41.             this->positions[i] = positions[i];
  42.         }
  43.     }
  44. };
  45.  
  46. class ListDepartment
  47. {
  48. public:
  49.     static const int SIZE_LIST = 3;
  50.     static string departments[SIZE_LIST];
  51.  
  52.     ListDepartment()
  53.     {
  54.         departments[0] = "null";
  55.         departments[1] = "one";
  56.         departments[2] = "two";
  57.     }
  58. };
  59.  
  60. class ListPosition
  61. {
  62. public:
  63.     static const int SIZE_LIST = 4;
  64.     static string positions[SIZE_LIST];
  65.  
  66.     ListPosition()
  67.     {
  68.         positions[0] = "_null";
  69.         positions[1] = "_one";
  70.         positions[2] = "_two";
  71.         positions[3] = "_three";
  72.     }
  73. };
  74.  
  75. int main()
  76. {
  77.     Employee staff("Andrey", 33, "one", "teacher");
  78.     string name;
  79.     Employee employee[Department::SIZE_STAFF];
  80.     string positions[Department::SIZE_POSITIONS];
  81.     int idDepartment;
  82.     int idPosition;
  83.    
  84.     for (int i = 0; i < Department::SIZE_STAFF; ++i) {
  85.         cout << "Enter name: "; cin >> employee[i].name;
  86.         cout << "Enter age: "; cin >> employee[i].age;
  87.         //выводим на экран список отделов
  88.         for (int j = 0; j < ListDepartment::SIZE_LIST; ++j) {
  89.             cout << ListDepartment::departments[i] << endl;
  90.         }
  91.         //выводим номер отдела
  92.         cout << "Enter department: "; cin >> idDepartment;
  93.         switch (idDepartment)
  94.         {
  95.             case 1:
  96.                 employee[i].department = ListDepartment::departments[idDepartment];
  97.                 break;
  98.             case 2:
  99.                 employee[i].department = ListDepartment::departments[idDepartment];
  100.                 break;
  101.             default:
  102.                 employee[i].department = ListDepartment::departments[0];
  103.                 break;
  104.         }
  105.         //выводим на экран список должностей
  106.         for (int j = 0; j < ListPosition::SIZE_LIST; ++j) {
  107.             cout << ListPosition::positions[j] << endl;
  108.         }
  109.         //выводим номер должности
  110.         cout << "Enter position: "; cin >> idPosition;
  111.         switch(idPosition)
  112.         {
  113.             case 1:
  114.                 employee[i].position = ListPosition::positions[idPosition];
  115.                 break;
  116.             case 2:
  117.                 employee[i].position = ListPosition::positions[idPosition];
  118.                 break;
  119.             case 3:
  120.                 employee[i].position = ListPosition::positions[idPosition];
  121.                 break;
  122.             default:
  123.                 employee[i].position = ListPosition::positions[0];
  124.                 break;
  125.         }
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement