-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSmartStoreApp.java
More file actions
60 lines (49 loc) · 1.96 KB
/
SmartStoreApp.java
File metadata and controls
60 lines (49 loc) · 1.96 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
package me.smartstore;
import me.smartstore.customer.CustomerRepository;
import me.smartstore.group.Group;
import me.smartstore.group.GroupParameter;
import me.smartstore.menu.Menu;
import me.smartstore.menu.topic.StartMenu;
public class SmartStoreApp {
private static final SmartStoreApp INSTANCE = new SmartStoreApp();
private SmartStoreApp() {}
public static SmartStoreApp getInstance() { return INSTANCE; }
public SmartStoreApp test() {
Integer[][] groupParameters = new Integer[][] {
{10, 100_000},
{20, 200_000},
{30, 300_000}
};
CustomerRepository repository = CustomerRepository.getInstance();
Group[] groups = Group.getUsedGroups();
for (int i = 0; i < groups.length; i++) {
Group group = groups[i];
Integer[] param = groupParameters[i];
group.setGroupParameter(param);
for (int j = 0; j < 10; j++) {
repository.resetTempCustomer();
String id = String.format("%s_%02d", group.name(), j);
repository.setTempId(id);
String name = (char) ('a'+j) + "zzz";
repository.setTempName(name);
Integer spentHours = (int) (Math.random() * 10) + param[0];
repository.setTempSpentHours(spentHours);
Integer totalPaidAmount = (int) (Math.random() * 100_000) + param[1];
repository.setTempTotalPaidAmount(totalPaidAmount);
repository.updateGroupOfTempCustomer();
repository.addTempIntoRepository();
}
}
return this;
}
public void run() {
Menu menu = StartMenu.getInstance();
do {
Menu nextMenu = menu.printAndInputAndGetNextMenu();
if (nextMenu == null)
return;
nextMenu.setPrevMenu(menu);
menu = nextMenu;
} while (true);
}
}