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