-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12week_9.cpp
154 lines (148 loc) · 3 KB
/
12week_9.cpp
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
#include <iostream>
#include <string>
using namespace std;
class console{
static int num;
static int time;
static int seatnum;
static string name;
public:
static int gettime(){
return time;
}
static int getseatnum(){
return seatnum;
}
static int getnum(){
return num;
}
static string getname(){
return name;
}
static void menu(){
cout << endl << endl << "에약:1, 최소:2, 보기:3, 끝내기:4>>"; cin >> num;
}
static void selectT(){
while (true){
cout << "07시:1, 12시:2, 17시:3>>"; cin >> time;
if (time == 1 || 2 || 3){
break;
}
else{
cout << "1~3을 입력해주세요." << endl;
}
}
}
static void selectSN(){
while (true){
cout << "좌석번호>> "; cin >> seatnum;
if (seatnum > 0 && seatnum < 9){
break;
}
else{
cout << "1~8을 선택해주세요." << endl;
}
}
cout << "이름 입력>> "; cin >> name;
}
};
int console::num;
int console::time;
int console::seatnum;
string console::name;
class seat{
string name;
public:
seat(){
this->name = "- - -";
}
string getN(){
return name;
}
void setN(string name){
this->name = name;
}
void show(){
cout << this->name;
}
};
class Schedule{
seat *s;
string n;
public:
Schedule(){
s = new seat[8];
}
~Schedule(){
delete[] s;
}
void setn(string n){
this->n = n;
}
string getN(int sn){
return s[sn].getN();
}
void setN(int sn, string name){
s[sn].setN(name);
}
void show(){
cout << n;
for (int i = 0; i < 8; i++){
cout << " "; s[i].show();
}
cout << endl;
}
};
class AirlineBook{
Schedule *sc;
public:
AirlineBook(){
sc = new Schedule[3];
sc[0].setn("07시");
sc[1].setn("12시");
sc[2].setn("17시");
}
~AirlineBook(){
delete[] sc;
}
void run(){
cout << "***** 한성항공에 오신것을 환영합니다 *****";
while (true){
console::menu();
if (console::getnum() == 1){
console::selectT(); //static맴버 time에 시간 저장
sc[console::gettime() - 1].show(); //시간에 예약된 명단 출력
console::selectSN(); //자리 번호, 이름 입력
if ("- - -" == sc[console::gettime() - 1].getN(console::getseatnum() - 1)){
sc[console::gettime() - 1].setN(console::getseatnum() - 1, console::getname()); // 자리 예약
}
else{
cout << "이미 예약된 자리입니다." << endl;
}
}
else if (console::getnum() == 2){
console::selectT(); //static맴버 time에 시간 저장
sc[console::gettime() - 1].show(); //시간에 예약된 명단 출력
console::selectSN(); //자리 번호, 이름 입력
if (console::getname() == sc[console::gettime() - 1].getN(console::getseatnum() - 1)){
sc[console::gettime() - 1].setN(console::getseatnum() - 1, "- - -");
}
else{
cout << "예약자명이 올바르지 않습니다." << endl;
}
}
else if (console::getnum() == 3){
for (int i = 0; i < 3; i++){
sc[i].show();
}
}
else if (console::getnum() == 4){
break;
}
}
}
};
int main(){
AirlineBook ab;
ab.run();
}