-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInterface.cpp
More file actions
199 lines (157 loc) · 4.11 KB
/
UserInterface.cpp
File metadata and controls
199 lines (157 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//UserInterface.cpp
//Made by Boyko Michael & Schotkin Maksim
// @@@@ SHOBO @@@@
// ****POWERED BY FRIENDSHIP****
// @@@@*******@@@@
// _____ _ _ ____ ____ ____
// / ____| | | |/ __ \| _ \ / __ \
// | (___ | |__| | | | | |_) | | | |
// \___ \| __ | | | | _ <| | | |
// ____) | | | | |__| | |_) | |__| |
// |_____/|_| |_|\____/|____/ \____/
//Version 1.0
#include <iostream>
#include <stdexcept>
#include <string>
#include "LibraryStaff.h"
using namespace std;
using namespace Library;
int displayMenu();
void doHire(LibraryStaff& staff);
void doFire(LibraryStaff& staff);
void doUpdateJob(LibraryStaff& staff);
void doUpdateSalary(LibraryStaff& staff);
void doUpdateYOS(LibraryStaff& staff);
int main(int argc, char** argv)
{
LibraryStaff libraryStaff;
bool running = true;
while(running){
int selection = displayMenu();
switch (selection) {
case 1:
doHire(libraryStaff);
break;
case 2:
doFire(libraryStaff);
break;
case 3:
doUpdateJob(libraryStaff);
break;
case 4:
doUpdateYOS(libraryStaff);
break;
case 5:
libraryStaff.displayAll();
break;
case 6:
libraryStaff.displayCurrent();
break;
case 7:
libraryStaff.displayFormer();
break;
case 0:
running = false;
break;
default:
cerr<<"Невідома команда!"<<endl;
break;
}
}
}
int displayMenu()
{
int selection;
cout<<endl;
cout<<"Термінал адміністратора бібліотеки"<<endl;
cout<<"**********************************"<<endl;
cout<<"[1] Найняти робітника"<<endl;
cout<<"[2] Звільнити робітника"<<endl;
cout<<"[3] Змінити посаду"<<endl;
cout<<"[4] Змінити стаж роботи"<<endl;
cout<<"[5] Перелік робітників"<<endl;
cout<<"[6] Перелік найнятих робітників"<<endl;
cout<<"[7] Перелік звільнених робітників"<<endl;
cout<<"[0] Завершення роботи"<<endl;
cout<<"**********************************"<<endl;
cout<<endl;
cin >> selection;
return selection;
}
void doHire(LibraryStaff& librarianList)
{
string name;
string job;
int salary;
string gender;
int age;
string adress;
string passport;
cout<<"Введіть ім'я: "<<endl;
cin>>name;
cout<<"Введіть посаду: "<<endl;
cin>>job;
cout<<"Введіть заробітну плату: "<<endl;
cin>>salary;
cout<<"Введіть стать: "<<endl;
cin>>gender;
cout<<"Введіть вік: "<<endl;
cin>>age;
cout<<"Введіть адресу: "<<endl;
cin>>adress;
cout<<"Введіть номер паспорту: "<<endl;
cin>>passport;
try {
librarianList.addLibrarian(name, job, salary, gender, age, adress, passport);
}
catch (std::exception ex){
cerr<<"Неможливо найняти робітника!"<<endl;
}
}
void doFire(LibraryStaff& librarianList)
{
int id;
cout<<"Введіть номер робітника: "<<endl;
cin>>id;
try{
Librarian& librarian = librarianList.getLibrarian(id);
librarian.Fire();
}
catch(std::exception ex){
cerr<<"Неможливо звільнити робітника!"<<endl;
}
}
void doUpdateJob(LibraryStaff& librarianList)
{
string job;
int salary;
int id;
cout<<"Введіть номер робітника: "<<endl;
cin>>id;
Librarian& librarian = librarianList.getLibrarian(id);
if(!librarian.getHireStatus()){
cout<<"Робітник не найнятий!"<<endl;
}
else{
cout<<"Введіть нову посаду: "<<endl;
cin>>job;
cout<<"Введіть нову базову зарплату: "<<endl;
cin>>salary;
librarian.setJob(job);
librarian.setBaseSalary(salary);
}
}
void doUpdateYOS(LibraryStaff& librarianList)
{
int yearsOfService;
int id;
cout<<"Введіть номер робітника: "<<endl;
cin>>id;
Librarian& librarian = librarianList.getLibrarian(id);
if(!librarian.getHireStatus()){
cout<<"Робітник не найнятий!"<<endl;
}
cout<<"Введіть стаж роботи: "<<endl;
cin>>yearsOfService;
librarian.setYearsOfService(yearsOfService);
}