-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrder.java
145 lines (112 loc) · 3.09 KB
/
Order.java
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
import java.util.ArrayList;
import java.util.Random;
// OrderInterface isWeekend Issue
public class Order implements OrderInterface, Comparable<Order> {
private int orderTime;
private DAY orderDay;
private int orderNo;
private Customer customer;
private ArrayList<Beverage> beverages;
public Order(int ot, DAY od, Customer c) {
customer = c;
orderNo = genOrderNum();
orderTime = ot;
orderDay = od;
beverages = new ArrayList<>();
}
public int genOrderNum() {
Random rand = new Random();
int randInt = rand.nextInt(90_000-10_000)+10_000;
return randInt;
}
public String toString() {
String s = "__________________________________" +orderDay.toString() +", " +orderTime +"\n" +customer.toString() +" Order Num: " +orderNo;
for (Beverage b : beverages) {
s += "\n" +b.toString();
}
s += "\n Order Total: " +calcOrderTotal();
return s;
}
public boolean isWeekend() {
if (orderDay == DAY.SATURDAY || orderDay == DAY.SUNDAY) {
return true;
}
return false;
}
public Beverage getBeverage(int itemNum) {
return beverages.get(itemNum);
}
public int compareTo(Order o) {
if (orderNo == o.getOrderNo()) {
return 0;
}
else if (orderNo > o.getOrderNo()) {
return 1;
}
else {
return -1;
}
}
public double calcOrderTotal() {
double orderTotal = 0;
for (Beverage b : beverages) {
orderTotal += b.calcPrice();
}
return orderTotal;
}
public int findNumOfBeveType(TYPE type) {
int count = 0;
for (Beverage b : beverages) {
if (b.getType() == type) {
count++;
}
}
return count;
}
public int getTotalItems() {
return beverages.size();
}
public void addNewBeverage(String name, SIZE size, int numOfFruits, boolean proteinPowder) {
Smoothie s = new Smoothie(name, size, numOfFruits, proteinPowder);
beverages.add(s);
}
public void addNewBeverage(String name, SIZE size) {
boolean isWeekend = false;
if (orderDay == DAY.SATURDAY || orderDay == DAY.SUNDAY) {
isWeekend = true;
}
Alcohol a = new Alcohol(name, size, isWeekend);
beverages.add(a);
}
public void addNewBeverage(String name, SIZE size, boolean extraShot, boolean extraSyrup) {
Coffee c = new Coffee(name, size, extraShot, extraSyrup);
beverages.add(c);
}
public int getOrderNo() {
return orderNo;
}
public int getOrderTime() {
return orderTime;
}
public DAY getOrderDay() {
return orderDay;
}
public Customer getCustomer() {
return new Customer(customer);
}
public ArrayList<Beverage> getBeverages() {
return beverages;
}
public void setOrderDay(DAY od) {
orderDay = od;
}
public void setCustomer(Customer c) {
customer = c;
}
public void setOrderNum(int on) {
orderNo = on;
}
public void setOrderTime(int ot) {
orderTime = ot;
}
}