-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuHandler.java
More file actions
161 lines (121 loc) · 3.85 KB
/
Copy pathMenuHandler.java
File metadata and controls
161 lines (121 loc) · 3.85 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
package POS24;
import java.util.Scanner;
public class MenuHandler {
Scanner sc = new Scanner(System.in);
MenuManager mm = MenuManager.getInstance();
int sel, sel2, sel3;
//시간 시작
long startTime = System.currentTimeMillis();
public void totalService() {
while(true) {
System.out.println("무엇을 도와드릴까요??");
System.out.println("1. 판매자");
System.out.println("2. 구매자");
System.out.println("9. 종료하기");
System.out.println("입력 : ");
int sel = sc.nextInt();
if(sel==1) {
sellerService();
}
else if(sel==2) {
buyerService();
}
else if(sel==9) {
quit();
}
else {
System.out.println("다시 입력해주세요.");
}
}
}
public void quit() {
//시간 끝
//시분초 설정
long endTime = System.currentTimeMillis();
long time = (endTime - startTime)/1000;
long hour, minute, second;
hour = time/(60*60);
minute = time/60;
second = time%60;
System.out.println(hour + " 시 " +minute + " 분 " + second + " 초 일하셨습니다.");
System.out.println("분급은 " + (minute*9800) + "원 입니다.");
System.out.println("오늘 하루도 수고하셨습니다.");
System.out.println("-----종료-----");
System.exit(0);
}
//판매자 시스템
public void sellerService() {
System.out.println("-----판매자 시스템-----");
System.out.println("----- 기능 선택 -----");
System.out.println("1. 등록");
System.out.println("2. 삭제");
System.out.println("3. 목록");
System.out.println("4. 검색");
System.out.println("0. 뒤로가기");
sel2 = sc.nextInt();
if(sel2==1) {
System.out.println("물품 정보 입력");
System.out.println("상품 이름 : ");
String Mname = sc.next();
System.out.println("상품 원산지 : ");
String Mfrom = sc.next();
System.out.println("상품 바코드 : ");
String Mbacord = sc.next();
System.out.println("상품 가격 : ");
int Mprice = sc.nextInt();
System.out.println("폐기날짜 : ");
String Mdate = sc.next();
System.out.println("성인(Y/N) : ");
String M19 = sc.next();
System.out.println("상품 수량 : ");
int Mamount = sc.nextInt();
mm.add(Mname, Mfrom, Mbacord, Mprice, Mdate, M19, Mamount);
}
else if (sel2==2) {
System.out.println("삭제할 상품의 바코드를 입력하세요.");
sc.nextLine();
String Mbacord = sc.nextLine();
mm.remove(Mbacord);
}
else if(sel2==3) {
mm.list();
}
else if(sel2==4) {
System.out.println("검색할 상품 바코드를 입력하세요.");
sc.nextLine();
String Mbacord = sc.nextLine();
mm.search(Mbacord);
}
else if(sel2==0) {
totalService();
}
else {
System.out.println("다시 입력해주세요.");
}
}
//구매자 시스템
public void buyerService() {
System.out.println("-----구매자 시스템-----");
System.out.println("-----기능 선택-----");
System.out.println("1. 구매하기");
System.out.println("0. 뒤로가기");
sel3 = sc.nextInt();
if(sel3==1) {
System.out.println("구매할 상품의 이름을 입력하세요");
sc.nextLine();
String Mname = sc.nextLine();
mm.search(Mname);
System.out.println("구매할 개수를 입력하세요");
int num = sc.nextInt();
System.out.println("카드로 결제하시겠습니까? (Y/N)");
String YorN = sc.next();
mm.update(Mname, num);
}
else if(sel3==0) {
totalService();
}
else {
System.out.println("다시 입력해주세요.");
}
}
}