일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- mac terminal command
- 토큰경제
- html youtube
- #CallByAddress
- html charset
- html code
- #C++ 연산자함수오버로딩
- html plug-in
- #bubbleSort
- hyperledger transaction
- 하이퍼레저패브릭
- #1차원배열
- #2차원배열
- relative path
- html5 new tag
- #android activity
- #C++ has~a
- border-box
- html video
- #3차원배열
- #JAVASCRIPT
- #binary
- docker example
- #자바상속#자바이즈어#is~a
- #다차원포인터
- #성적관리프로그램
- html object
- html id
- html multimedia
- git flow
Archives
- Today
- Total
A sentimental robot
Has~a exercise 본문
menue.h
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 |
#pragma once
#include<iostream>
#include<string>
#include"admin.h"
#include"user.h"
using namespace std;
class Menu {
Admin admin;
User *user;
string adminID;
int adminPass;
int userNum;
int userPass;
int a;
public: Menu() {
user = new User(&admin);
menu();
}
void menu() {
while (1) {
cout << "==== 급여관리 프로그램입니다.====" << endl;
cout << "1. 관리자 모드 " << "\t" << "2. 사용자 모드" << endl;
cin >> a;
switch (a) {
case 1:
{
cout << "관리자ID를 입력하세요 =>";
cin >> adminID;
if (admin.loginID(adminID)) {
cout << "비밀번호를 입력하세요 =>";
cin >> adminPass;
if (admin.loginPass(adminPass)) {
cout << "=== Login Success ===" << endl;
// 관리자 로그인모드
admin.adminMode();
}else {
cout << "비밀번호가 틀렸습니다." << endl; continue;
}
}else {
cout << "관리자ID가 틀렸습니다." << endl; continue;
}
}break;
case 2:
{
cout << "사원번호를 입력하세요:";
cin >> userNum;
if (user->loginID(userNum)) {
cout << "비밀번호를 입력하세요 =>";
cin >> userPass;
if (user->loginPass(userPass)) {
cout << "=== User Login Success ===" << endl;
// 사용자모드
user->userSearch();
}
else {
cout << "비밀번호가 틀렸습니다." << endl; continue;
}
}
else {
cout << "사원번호가 존재하지 않습니다. " << endl;
}
} break;
default:cout << "잘못된 입력입니다." << endl; break;
}
}
}
};
|
cs |
admin.h
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256 |
#pragma once
#include<iostream>
//#include<iterator>
#include<string>
#include"userDB.h"
using namespace std;
static int c = 0;
class Admin {
string name;
string position;
string department;
int userNum;
int password;
double salary;
int age;
string adminID;
int pass;
public:
UserDB userdb[100];
int arraySize;
Admin() {
adminID = "admin";
pass = 0000;
} // Admin constructor
bool loginID(string adminID) {
if (this->adminID == adminID)
return true;
else return false;
}
bool loginPass(int pass) {
if (this->pass == pass)
return true;
else return false;
}// 관리자 로그인
void adminMode() {
int a;
cout << "[관리자 모드입니다.] " << endl;
cout << "1. 사용자 추가 2. 사용자 조회 3. 사용자 삭제 4. 사용자 정보수정" << endl;
cin >> a;
switch (a) {
case 1:setUserDB(); break;
case 2:search(); break;
case 3:deleteUser(); break;
case 4:update(); break;
default: cout << "잘못된 입력입니다." << endl; break;
}
}// 관리자 메뉴
void setUserDB() {
cout << "사원 이름을 입력하세요:";
cin >> name;
setUserName(name);
cout << "직급을 입력하세요:";
cin >> position;
setUserPosition(position);
cout << "부서를 입력하세요:";
cin >> department;
setUserDepartment(department);
cout << "사원번호를 입력하세요:";
cin >> userNum;
setUserNum(userNum);
cout << "비밀번호를 입력하세요:";
cin >> password;
setUserPass(password);
cout << "급여를 입력하세요:";
cin >> salary;
setUserSalary(salary);
cout << "나이를 입력하세요:";
cin >> age;
setUserAge(age);
cout << "*사용자가 추가되었습니다.*" << endl;
c++;
arraySize = sizeof(userdb[c]) / sizeof(userdb[0]);
}
void setUserName(string name) {
userdb[c].setName(name);
}
void setUserPosition(string position) {
userdb[c].setPosition(position);
}
void setUserDepartment(string department) {
userdb[c].setDepartment(department);
}
void setUserNum(int userNum) {
userdb[c].setNum(userNum);
}
void setUserPass(int pass) {
userdb[c].setPass(pass);
}
void setUserSalary(double salary) {
userdb[c].setSalary(salary);
}
void setUserAge(int age) {
userdb[c].setAge(age);
}
// 1. 사용자 추가
void search() {
int number;
int checking_ID;
// cout << arraySize << endl;
cout << "1.전체조회 2.개인조회" << endl;
cin >> number;
switch (number)
{
case 1:
{
cout << "전체 사원 리스트" << endl;
for (int i = 0; i < arraySize; i++)
{
cout << userdb[i].getNum() << "\t" << userdb[i].getName() << "\t" << userdb[i].getAge() << "\t" << userdb[i].getDepartment() << "\t" << userdb[i].getPosition() << "\t" << userdb[i].getSalary() << "\t" << userdb[i].getPass() << endl;
}
}break;
case 2:
{
cout << "조회할 사원번호를 입력해주세요 :";
cin >> checking_ID;
for (int i = 0; i < arraySize; i++)
{
if (checking_ID == userdb[i].getNum())
{
cout << userdb[i].getNum() << "\t" << userdb[i].getName() << "\t" << userdb[i].getAge() << "\t" << userdb[i].getDepartment() << "\t" << userdb[i].getPosition() << "\t" << userdb[i].getSalary() << "\t" << userdb[i].getPass() << endl;
}
}
}break;
default: cout << "잘못 입력하셨습니다." << endl; break;
}
}
// 2. 사용자 조회
void deleteUser() {
int checking_ID;
cout << "삭제할 사원번호를 입력하세요:";
cin >> checking_ID;
for (int i = 0; i < arraySize; i++)
{
if (checking_ID == (userdb[i].getNum()))
{
for (int j = i; i < arraySize - i; i++)
{
userdb[i] = userdb[i + 1];
}
--c;
}
}
}
// 3. 사용자 삭제
void update() {
int number;
int checking_ID;
cout << "수정할 ID를 입력하세요: ";
cin >> checking_ID;
for (int i = 0; i < arraySize; i++)
{
if (checking_ID == (userdb[i].getNum()))
{
cout << "사원 이름을 입력하세요:";
cin >> name;
userdb[i].setName(name);
cout << "직급을 입력하세요:";
cin >> position;
userdb[i].setPosition(position);
cout << "부서를 입력하세요:";
cin >> department;
userdb[i].setDepartment(department);
cout << "사원번호를 입력하세요:";
cin >> userNum;
userdb[i].setNum(userNum);
cout << "비밀번호를 입력하세요:";
cin >> password;
userdb[i].setPass(password);
cout << "급여를 입력하세요:";
cin >> salary;
userdb[i].setSalary(salary);
cout << "나이를 입력하세요:";
cin >> age;
userdb[i].setAge(age);
cout << "*사원 정보가 수정되었습니다.*" << endl;
}
}
} // 4. 사용자 정보수정
}; // Admin class |
cs |
userDB.h
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 |
#pragma once
#include<iostream>
#include<string>
using namespace std;
class UserDB {
string name;
string position;
string department;
int userNum;
int password;
double salary;
int age;
public:
UserDB()
{
}
void setName(string name)
{
this->name = name;
}
string getName()const {
return name;
}
void setAge(int age)
{
this->age = age;
}
int getAge()const {
return age;
}
void setNum(int userNum)
{
this->userNum = userNum;
}
int getNum()const {
return userNum;
}
void setPass(int password)
{
this->password = password;
}
int getPass()const {
return password;
}
void setDepartment(string department)
{
this->department = department;
}
string getDepartment()const {
return department;
}
void setPosition(string position)
{
this->position = position;
}
string getPosition()const {
return position;
}
void setSalary(double salary)
{
this->salary = salary;
}
double getSalary()const {
return salary;
}
}; |
cs |
user.h
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 |
#pragma once
#include<iostream>
#include<string>
#include"admin.h"
using namespace std;
class User { // 로그인과 조회
Admin *admin;
int userNum;
int pass;
int checking_ID;
int i; // 사원모드에서는 해당 사원만 조회 가능
public:
User(Admin*admin) {
this->admin = admin;
}
bool loginID(int userNum) {
for (int i = 0; i < admin->arraySize; i++) {
if (userNum == admin->userdb[i].getNum())
return true;
}return false;
}
bool loginPass(int pass) {
for (int i = 0; i < admin->arraySize; i++) {
if (pass == admin->userdb[i].getPass())
return true;
}return false;
}
// 사용자 로그인
void userSearch() {
cout << admin->userdb[i].getNum() << "\t" << admin->userdb[i].getName() << "\t" << admin->userdb[i].getAge() << "\t" << admin->userdb[i].getDepartment() << "\t" << admin->userdb[i].getPosition() << "\t" << admin->userdb[i].getSalary() << "\t" << admin->userdb[i].getPass() << endl;
}
// 사용자 조회(본인)
};
|
cs |