-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathApplication.java
More file actions
71 lines (60 loc) · 2.33 KB
/
Application.java
File metadata and controls
71 lines (60 loc) · 2.33 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
package store;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import store.controller.StoreController;
public class Application {
public static void main(String[] args) {
// TODO: 프로그램 구현
System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8));
AppConfig appConfig = new AppConfig();
new Application().run(appConfig);
}
public void run(AppConfig appConfig){
boolean repeatInput = true;
boolean repeatProgram = true;
StoreController storeController = appConfig.getStoreController();
String accessingUserID = storeController.initializing();
while(repeatProgram){
storeController.startPurchase();
while(repeatInput){
repeatInput = storeController.purchasing(accessingUserID);
}
repeatInput = true;
while(repeatInput){
int result = storeController.endPurchase(accessingUserID);
if(result < 1) repeatInput = false;
if(result < 0) repeatProgram = false;
}
repeatInput = true;
}
storeController.disconnectUser(accessingUserID);
}
public void testRun(AppConfig appConfig, Breakpoint breakpoint){
boolean repeatInput = true;
boolean repeatProgram = true;
StoreController storeController = appConfig.getStoreController();
String accessingUserID = storeController.initializing();
while(repeatProgram){
storeController.startPurchase();
if(breakpoint==Breakpoint.PRODUCT_GUIDE) break;
while(repeatInput){
repeatInput = storeController.purchasing(accessingUserID);
if(breakpoint==Breakpoint.FIRST_PURCHASE_ATTEMPT) break;
}
if(breakpoint==Breakpoint.FIRST_PURCHASE_ATTEMPT) break;
repeatInput = true;
while(repeatInput){
int result = storeController.endPurchase(accessingUserID);
if(result < 1) repeatInput = false;
if(result < 0) repeatProgram = false;
}
repeatInput = true;
}
storeController.disconnectUser(accessingUserID);
}
public enum Breakpoint{
PRODUCT_GUIDE,
FIRST_PURCHASE_ATTEMPT,
NONE
}
}