-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathMain.java
More file actions
93 lines (75 loc) · 3.74 KB
/
Main.java
File metadata and controls
93 lines (75 loc) · 3.74 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
package com.booleanuk.core;
import com.booleanuk.core.Products.Bagel;
import com.booleanuk.core.Products.Filling;
import com.booleanuk.core.Products.Product;
import java.sql.Time;
import java.util.List;
public class Main {
public static void main(String[] args) {
System.out.println("\n");
// Load inventory on start
Inventory inv = loadInventoryOnStart();
List<Product> list = inv.getInventoryList();
// inv.printInventory();
Basket basket = new Basket("small", 5);
Customer customer = new Customer(basket, list);
Bagel bagel1 = new Bagel("BGLO", 0.49f, "Onion", Product.ProductType.BAGEL);
Bagel bagel2 = new Bagel("BGLP", 0.39f, "Plain", Product.ProductType.BAGEL);
Bagel bagel3 = new Bagel("BGLE", 0.49f, "Everything", Product.ProductType.BAGEL);
Bagel bagel4 = new Bagel("BGLS", 0.49f, "Sesame", Product.ProductType.BAGEL);
Bagel bagel5 = new Bagel("BGLS", 0.49f, "Sesame", Product.ProductType.BAGEL);
Bagel bagel6 = new Bagel("BGLS", 0.49f, "Sesame", Product.ProductType.BAGEL);
// Story 1:
Time time = Time.valueOf("07:45:00");
String s = customer.orderBagelAtSpecificTime(time, "everything");
System.out.println(s);
// Story 2:
customer.addBagelToBasket(bagel1);
customer.removeBagelFromBasket(bagel1);
// Story 3:
customer.addBagelToBasket(bagel1);
customer.addBagelToBasket(bagel2);
customer.addBagelToBasket(bagel3);
customer.addBagelToBasket(bagel4);
customer.addBagelToBasket(bagel5);
customer.addBagelToBasket(bagel6); // full
// Story 4:
Manager manager = new Manager(inv);
manager.changeBasketCapacity(basket, 10);
customer.addBagelToBasket(bagel6); // not full anymore
// Story 5:
customer.removeBagelFromBasket(bagel1); // should remove
customer.removeBagelFromBasket(bagel1); // nothing to remove
// Story 6:
System.out.println(customer.getTotalCost());
// Story 7:
System.out.println(customer.getBagelPrice(bagel4));
// Story 8 and 9:
customer.viewFillingsAndPrice();
customer.getBagelAndPickFilling("cheese");
// Story 10:
Bagel test = new Bagel("sku123", 10f, "test", Product.ProductType.BAGEL);
Bagel test2 = new Bagel("sku999", 10f, "test", Product.ProductType.BAGEL);
manager.addItemToInv(test);
customer.addBagelToBasket(test); // should work
customer.addBagelToBasket(test2); // should not work
}
public static Inventory loadInventoryOnStart() {
// Add all items to the inventory
Inventory inventory = new Inventory();
// Add Bagels
inventory.addProduct(new Bagel("BGLO", 0.49f, "Onion", Product.ProductType.BAGEL));
inventory.addProduct(new Bagel("BGLP", 0.39f, "Plain", Product.ProductType.BAGEL));
inventory.addProduct(new Bagel("BGLE", 0.49f, "Everything", Product.ProductType.BAGEL));
inventory.addProduct(new Bagel("BGLS", 0.49f, "Sesame", Product.ProductType.BAGEL));
// Add Fillings
inventory.addProduct(new Filling("FILB", 0.12f, "Bacon", Product.ProductType.FILLING));
inventory.addProduct(new Filling("FILE", 0.12f, "Egg", Product.ProductType.FILLING));
inventory.addProduct(new Filling("FILC", 0.12f, "Cheese", Product.ProductType.FILLING));
inventory.addProduct(new Filling("FILX", 0.12f, "Cream Cheese", Product.ProductType.FILLING));
inventory.addProduct(new Filling("FILS", 0.12f, "Smoked Salmon", Product.ProductType.FILLING));
inventory.addProduct(new Filling("FILH", 0.12f, "Ham", Product.ProductType.FILLING));
// Add Coffees
return inventory;
}
}