-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek5_2.java
193 lines (170 loc) · 4.38 KB
/
week5_2.java
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
import java.util.Scanner;
public class week5_2 {
static class consert{
private String name[] = new String[10];
public consert(String n) {
for(int i = 0; i < 10; i++) {
name[i] = n;
};
}
void show() {
for(int i = 0; i < 10; i++) {
System.out.print(" " + name[i] + " ");
};
System.out.print("\n");
}
String getName(int a)
{
return name[a];
}
void setName(String n, int a) {name[a] = n;}
};
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
consert S = new consert("---");
consert A = new consert("---");
consert B = new consert("---");
System.out.println("명품콘서트홀 예약 시스템입니다.");
do {
System.out.print("예약:1, 조회:2, 취소:3, 끝내기:4>>");
int num = sc.nextInt();
if(num == 1) {
System.out.print("이름>>");
String name = sc.next();
do {
System.out.print("좌석구분 S(1), A(2), B(3)");
int s = sc.nextInt();
if(s == 1) {
do {
System.out.print("번호>>");
int x = sc.nextInt();
if(x > 0 && x < 11) {
if(S.getName(x - 1) != "---") { //이미 좌석이 예매되었을 때
System.out.println("이미 예약된 좌석입니다.");
}
else {
S.setName(name, x - 1);
break;
}
}
else {
System.out.println("1 ~ 10 까지 빈자리를 선택해주세요.");
}
}while(true);
}
else if(s == 2) {
do {
System.out.print("번호>>");
int x = sc.nextInt();
if(x > 0 && x < 11) {
if(A.getName(x - 1) != "---") { //이미 좌석이 예매되었을 때
System.out.println("이미 예약된 좌석입니다.");
}
else {
A.setName(name, x - 1);
break;
}
}
else {
System.out.println("1 ~ 10 까지 빈자리를 선택해주세요.");
}
}while(true);
}
else if(s == 3) {
do {
System.out.print("번호>>");
int x = sc.nextInt();
if(x > 0 && x < 11) {
if(B.getName(x - 1) != "---") { //이미 좌석이 예매되었을 때
System.out.println("이미 예약된 좌석입니다.");
}
else {
B.setName(name, x - 1);
break;
}
}
else {
System.out.println("1 ~ 10 까지 빈자리를 선택해주세요.");
}
}while(true);
}else {
System.out.println("1 ~ 3를 입력해주세요.");
}
break;
}while(true);
}
else if(num == 2) {
System.out.print("S>> ");
S.show();
System.out.print("\nA>> ");
A.show();
System.out.print("\nB>> ");
B.show();
System.out.println("<<조회를 완료하였습니다.>>");
}
else if(num == 3) {
System.out.print("좌석 S:1, A:2, B:3 >>");
int s = sc.nextInt();
if(s == 1) {
System.out.print("S>>");
S.show();
System.out.print("이름>>");
String name = sc.next();
for(int i = 0; i < 10; i++) {
if(S.getName(i).equals(name)) {
S.setName("---", i);
break;
}
else {
if(i == 10) {
System.out.println(name + "은 예약자 명단에 없습니다.");
}
}
}
}
else if(s == 2) {
System.out.print("A>>");
A.show();
System.out.print("이름>>");
String name = sc.next();
for(int i = 0; i < 10; i++) {
if(A.getName(i).equals(name)) {
A.setName("---", i);
break;
}
else {
if(i == 10) {
System.out.println(name + "은 예약자 명단에 없습니다.");
}
}
}
}
else if(s == 3) {
System.out.print("B>>");
B.show();
System.out.print("이름>>");
String name = sc.next();
for(int i = 0; i < 10; i++) {
if(B.getName(i).equals(name)) {
B.setName("---", i);
break;
}
else {
if(i == 10) {
System.out.println(name + "은 예약자 명단에 없습니다.");
}
}
}
}
else {
System.out.println("1 ~ 3을 입력해주세요.");
}
}
else if(num == 4) {
break;
}else {
System.out.println("1 ~ 4를 입력해주세요.");
}
}while(true);
}
}