-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathInvoice.java
More file actions
48 lines (47 loc) · 1.28 KB
/
Invoice.java
File metadata and controls
48 lines (47 loc) · 1.28 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
package restaurant;
import java.util.ArrayList;
public class Invoice {
private static final float tax_rate = 9.4f;
private int state = -1;
private Customer customer;
private ArrayList<Item> items = new ArrayList<>();
public Invoice(String customerName, Address customerAddress) {
this.customer = new Customer(customerName, customerAddress);
}
public Invoice(Customer c1) {
}
public int getState() {
return this.state;
}
public Customer getCustomer() {
return this.customer;
}
public boolean addItem(Item item) {
if (this.state == -1) {
this.items.add(item);
return true;
}
return false;
}
public boolean removeItem(Item item) {
if (this.state == -1 && this.items.contains(item)) {
this.items.remove(item);
return true;
}
return false;
}
public void nextStage() {
this.state++;
}
public int getTotalPrice() {
double total = 0;
for (Item item : this.items) {
total += item.getFood().getPrice() * item.getCount();
}
total += total * tax_rate / 100;
return (int) Math.ceil(total);
}
public ArrayList<Item> getItems() {
return this.items;
}
}