-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathInvoice.java
More file actions
52 lines (43 loc) · 1.11 KB
/
Invoice.java
File metadata and controls
52 lines (43 loc) · 1.11 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
import java.util.Vector;
class Invoice {
private static final float taxRate = 9.4;
private Customer customer;
private boolean acceptingOrder;
private Vector<Item> items;
public Invoice(Customer customer) {
this.customer = customer;
this.acceptingOrder = true;
this.items = new Vector<Item>();
}
public boolean addItem(Item item) {
if (acceptingOrder) {
items.add(item);
}
return acceptingOrder;
}
public boolean removeItem(Item item) {
if (acceptingOrder) {
return items.remove(item);
}
return false;
}
public void nextStage() {
this.acceptingOrder = false
}
public int getState() {
return state;
}
public int getTotalPrice() {
double total = 0;
for (Item item : items) {
total += item.getFood().getPrice() * item.getCount();
}
return (int) (total * (taxRate + 100) / 100);
}
public Customer getCustomer() {
return customer;
}
public Vector<Item> getItems() {
return items;
}
}