Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Employee
- {
- public:
- string name;
- int age;
- string department;
- string position;
- Employee(string name, int age, string department, string position)
- {
- this->name = name;
- this->age = age;
- this->department = department;
- this->position = position;
- }
- Employee() {}
- };
- class Department
- {
- public:
- static const int SIZE_STAFF = 3;
- static const int SIZE_POSITIONS = 3;
- string name;
- Employee staff[SIZE_STAFF];
- string positions[SIZE_POSITIONS];
- Department(){}
- Department(string name, Employee employee[], string positions[])
- {
- this->name = name;
- for (int i = 0; i < SIZE_STAFF; ++i) {
- staff[i] = employee[i];
- }
- for (int i = 0; i < SIZE_POSITIONS; ++i) {
- this->positions[i] = positions[i];
- }
- }
- };
- class ListDepartment
- {
- public:
- static const int SIZE_LIST = 3;
- static string departments[SIZE_LIST];
- ListDepartment()
- {
- departments[0] = "null";
- departments[1] = "one";
- departments[2] = "two";
- }
- };
- class ListPosition
- {
- public:
- static const int SIZE_LIST = 4;
- static string positions[SIZE_LIST];
- ListPosition()
- {
- positions[0] = "_null";
- positions[1] = "_one";
- positions[2] = "_two";
- positions[3] = "_three";
- }
- };
- int main()
- {
- Employee staff("Andrey", 33, "one", "teacher");
- string name;
- Employee employee[Department::SIZE_STAFF];
- string positions[Department::SIZE_POSITIONS];
- int idDepartment;
- int idPosition;
- for (int i = 0; i < Department::SIZE_STAFF; ++i) {
- cout << "Enter name: "; cin >> employee[i].name;
- cout << "Enter age: "; cin >> employee[i].age;
- //выводим на экран список отделов
- for (int j = 0; j < ListDepartment::SIZE_LIST; ++j) {
- cout << ListDepartment::departments[i] << endl;
- }
- //выводим номер отдела
- cout << "Enter department: "; cin >> idDepartment;
- switch (idDepartment)
- {
- case 1:
- employee[i].department = ListDepartment::departments[idDepartment];
- break;
- case 2:
- employee[i].department = ListDepartment::departments[idDepartment];
- break;
- default:
- employee[i].department = ListDepartment::departments[0];
- break;
- }
- //выводим на экран список должностей
- for (int j = 0; j < ListPosition::SIZE_LIST; ++j) {
- cout << ListPosition::positions[j] << endl;
- }
- //выводим номер должности
- cout << "Enter position: "; cin >> idPosition;
- switch(idPosition)
- {
- case 1:
- employee[i].position = ListPosition::positions[idPosition];
- break;
- case 2:
- employee[i].position = ListPosition::positions[idPosition];
- break;
- case 3:
- employee[i].position = ListPosition::positions[idPosition];
- break;
- default:
- employee[i].position = ListPosition::positions[0];
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement