-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
58 lines (44 loc) · 1.24 KB
/
Main.java
File metadata and controls
58 lines (44 loc) · 1.24 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
import java.io.IOException;
public class Main {
private static MarketSpace marketspace;
private static String company = "Best Buy";
public static void main(String[] args) {
System.out.println("Welcome to " + company + "\n");
boolean validMarket;
marketspace = MarketSpace.getInstance();
try {
validMarket = marketspace.loadProducts();
} catch (IOException e) {
System.out.println("\nSorry there is a problem loading the MarketSpace. \n"
+ "Please come back later.\n");
validMarket = false;
}
int cmd = 0;
while(cmd < 5 && validMarket) {
switch(cmd) {
case 0:
cmd = marketspace.marketHome();
break;
case 1:
Computer newDefault = marketspace.addToCart(null,null);
marketspace.viewCurrentOrder(newDefault);
cmd = marketspace.listProducts(newDefault);
break;
case 2:
marketspace.viewCart();
cmd = 0;
break;
case 3:
marketspace.sort(new SortByOrderID());
cmd = 0;
break;
case 4:
marketspace.sort(new SortByPrice());
cmd = 0;
break;
}
}
marketspace.userScan.close();
System.out.println("Thank you for shopping at " + company + ", see you next time.");
}
}