-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5th.cpp
More file actions
179 lines (158 loc) · 4.09 KB
/
5th.cpp
File metadata and controls
179 lines (158 loc) · 4.09 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
#include <iostream>
#include <string>
using namespace std;
string* pClass = new string[3]{ "c++ 프로그래밍","Linux 프로그래밍","리버싱" };
int i = 0;
class Member {
private:
string name;
string id, aid; // 회원가입 시 작성하는 아이디, 로그인 시 작성하는 아이디
int pwd, apwd; // 회원가입 시 등록하는 비밀번호, 로그인 시 작성하는 비밀번호
public:
void setName() {
cout << "이름: ";
cin >> name;
};
void setId() {
cout << "아이디: ";
cin >> id;
};
void setPassword() {
cout << "비밀번호: ";
cin >> pwd;
};
string getName() {
return name;
};
string getId() {
return id;
};
int getPassword() {
return pwd;
};
};
class Cart {
private:
string apply[3]{ "a", "b", "c" }; // 수강신청 과목이 들어갈 곳, 수강신청 이전의 값 임의로 설정
public:
void print() {
cout << endl;
for (i = 0; i < 3; i++) {
cout << "[" << i + 1 << "]" << pClass[i] << " >> 000";
cout << i + 1;
cout << endl;
}
}
void bag_course() {
string a_num;
cout << "추가할 학수 번호 >> ";
cin >> a_num;
{
if (a_num == "0001") {
if (apply[0] == "a") apply[0] = pClass[0];
else if (apply[1] == "b") apply[1] = pClass[0];
else apply[2] = pClass[0];
}
else if (a_num == "0002") {
if (apply[0] == "a") apply[0] = pClass[1];
else if (apply[1] == "b") apply[1] = pClass[1];
else apply[2] = pClass[1];
}
else if (a_num == "0003") {
if (apply[0] == "a") apply[0] = pClass[2];
else if (apply[1] == "b") apply[1] = pClass[2];
else apply[2] = pClass[2];
}
}
if (apply[0] == apply[1]) {
apply[1] = "b";
cout << "이미 MY 장바구니에 담겨져 있습니다." << endl;
}
else if (apply[1] == apply[2]) {
apply[2] = "c";
cout << "이미 MY 장바구니에 담겨져 있습니다." << endl;
}
else if (apply[2] == apply[0]) {
apply[2] = "c";
cout << "이미 MY 장바구니에 담겨져 있습니다." << endl;
}
}
void put_bag() {
cout << "======== MY 장바구니 ========" << endl;
cout << "1. ";
if (apply[0] != "a") cout << apply[0];
cout << endl;
cout << "2. ";
if (apply[1] != "b") cout << apply[1];
cout << endl;
cout << "3. ";
if (apply[2] != "c") cout << apply[2];
cout << endl;
}
};
int main() {
int apwd, x, y;
string aid;
Member account[3];
Member* p = account;
Cart applying;
while (1) {
cout << "------------- 서울여자대학교 종합정보시스템 -------------" << endl;
cout << "1. 회원가입" << endl;
cout << "2. 로그인" << endl;
cout << endl;
cout << "번호를 입력하세요 >> ";
cin >> x;
cout << "---------------------------------------------------------" << endl;
if (x == 1) {
cout << endl;
p[0].setName();
p[1].setId();
p[2].setPassword();
cout << "=== 회원가입 성공 ===" << endl;
}
else if (x == 2) {
cout << endl;
cout << "아이디: ";
cin >> aid;
cout << "비밀번호: ";
cin >> apwd;
{if ((p[1].getId() == aid) && (apwd == p[2].getPassword())) {
cout << endl;
cout << "=== 로그인 성공 ===" << endl;
cout << p[0].getName() << "님 환영합니다." << endl;
cout << endl;
break;
}
else cout << "아이디 혹은 비밀번호가 틀렸습니다." << endl;
}
}
else cout << "1 또는 2만 입력해주세요." << endl;
}
while (1) {
{cout << "===============" << endl;
cout << "1. 장바구니" << endl;
cout << "2. 강의 담기" << endl;
cout << "3. 수강신청 확인" << endl;
cout << "4. 로그아웃" << endl;
cout << "번호를 입력하세요: ";
cin >> y; }
switch (y) {
case(1):
applying.print();
break;
case(2):
applying.bag_course();
break;
case(3):
applying.put_bag();
break;
case(4):
cout << "---------- 로그아웃 ----------" << endl;
cout << "로그아웃 되었습니다. 안녕히 가세요." << endl;
return 0;
}
}
delete[] pClass;
return 0;
}