-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frame.java
222 lines (181 loc) · 5.12 KB
/
Frame.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
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
package java_gui;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.List;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Map;
import javax.swing.JFrame;
import java_gui.Field;
import java_gui.HomePage;
import java_gui.LogInPage;
import java_gui.MenuPage;
import java_gui.PaymentPage;
import java_gui.ResultPage;
import java_gui.SeatCheckPage;
class userPerson{
Field f = new Field();
public String name = f.getName();
public String phone = f.getPhone();
public int seat = f.getSeat();
// private String menu =
}
class Field{
public int[] seat = new int[11];
public userPerson arrayUser[] = new userPerson[11];
public String userName= "emptyName";
public String userPhone = "emptyPhone";
public int userSeat;
public int Price = 0;
public int count = 1;
public void setName(String name) {
userName = name;
}
public String getName() {
return userName;
}
public void setPhone(String phone) {
userPhone = phone;
}
public String getPhone() {
return userPhone;
}
public void setSeat(int seat) {
userSeat = seat;
}
public int getSeat() {
return userSeat;
}
public void setPrice(int Price) {
this.Price = Price;
}
public int getPrice() {
return this.Price;
}
public int[] getseatlist() {
return seat;
}
public void setseatlist(int[] seatlist) {
if(seatlist.length == 11)
seat = seatlist;
}
public void increaseCount() {
this.count++;
}
public int getCount() {
return this.count;
}
public void removeUser(userPerson user) {
//만약 user가 없을때 예외처리
for(int i = 0; i < 11; i++) {
if(arrayUser[i] == user)
arrayUser[i] = null;
}
}
public void addUser(String phone) {
userPerson newUser = new userPerson();
newUser.name = userName;
newUser.phone = userPhone;
newUser.seat = userSeat;
arrayUser[userSeat - 1] = newUser;
for(int i =0; i<11; i++) {
System.out.println(arrayUser[i]);
}
}
public userPerson findUser(String phone) {
for(int i = 0; i < 11; i++) {
if(arrayUser[i] != null)
if(arrayUser[i].phone.equals(phone))
return arrayUser[i];
}
return null;
}
}
public class Frame extends JFrame{
//각 페이지 레퍼런스들을 배열에 저장
PagePanel arrayPanel[];
int pageCount = 0;
private CardLayout cards = new CardLayout();
public Frame() {
super("융프2팀_스터디카페");
setSize(800, 600);
getContentPane().setLayout(cards);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
Field field = new Field();
//판넬 배열 할당
arrayPanel = new PagePanel[7];
HomePage home = new HomePage(this, field);
getContentPane().add("HomePage", home);
arrayPanel[pageCount] = home;
++pageCount;
LogInPage login = new LogInPage(this, field);
getContentPane().add("LogInPage", login);
arrayPanel[pageCount] = login;
++pageCount;
MenuPage menu = new MenuPage(this, field);
getContentPane().add("MenuPage", menu);
arrayPanel[pageCount] = menu;
++pageCount;
SeatCheckPage seatCheck = new SeatCheckPage(this, field);
getContentPane().add("SeatCheckPage", seatCheck);
arrayPanel[pageCount] = seatCheck;
++pageCount;
PaymentPage payment = new PaymentPage(this, field);
getContentPane().add("PaymentPage", payment);
arrayPanel[pageCount] = payment;
++pageCount;
ResultPage result = new ResultPage(this, field);
getContentPane().add("ResultPage", result);
arrayPanel[pageCount] = result;
++pageCount;
CheckOutPage checkout = new CheckOutPage(this, field);
getContentPane().add("CheckOutPage", checkout);
arrayPanel[pageCount] = checkout;
++pageCount;
setVisible(true);
}
public void nextPanel() {
cards.next(this.getContentPane());
}
public void prevPanel() {
cards.previous(this.getContentPane());
}
public void gotoCheckout() { // 퇴실페이지로 이동
Container parent = this.getContentPane();
synchronized (parent.getTreeLock()) {
int ncomponents = parent.getComponentCount();
Component comp = parent.getComponent(0);
if (comp.isVisible()) {
comp.setVisible(false);
int currentCard = 6 % ncomponents;
comp = parent.getComponent(currentCard);
comp.setVisible(true);
parent.validate();
return;
}
showDefaultComponent(parent);
}
}
void showDefaultComponent(Container parent) {
if (parent.getComponentCount() > 0) {
int currentCard = 0;
parent.getComponent(0).setVisible(true);
parent.validate();
}
}
public static void main(String[] args) {
Frame frm = new Frame();
}
public void InitFrame(Field field) {
for(int i = 0; i < pageCount;++i) {
arrayPanel[i].Init();
}
}
public void updatePage() {
for(int i = 0; i < pageCount;++i) {
arrayPanel[i].updatePage();
}
}
}