-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoice.java
More file actions
43 lines (36 loc) · 1.06 KB
/
Copy pathInvoice.java
File metadata and controls
43 lines (36 loc) · 1.06 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
import java.util.*;
import java.io.*;
public class Invoice implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private double grandTotal;
private static final String INVOICE_STRING = "I";
private List<CartItem> cart;
public Invoice(double grandTotal, List<CartItem> cart) {
this.id = INVOICE_STRING + (InvoiceIdServer.instance()).getId();
this.grandTotal = grandTotal;
this.cart = cart;
}
public String getId() {
return id;
}
public double getTotal() {
return grandTotal;
}
public void setTotal(double newTotal) {
grandTotal = newTotal;
}
public boolean equals(String id) {
return this.id.equals(id);
}
public void invoicePrdouble() {
Iterator<CartItem> carti = cart.iterator();
// Display ALL items
while (carti.hasNext()) {
CartItem cartItem = (CartItem) (carti.next());
String itemString = cartItem.toString();
System.out.println(itemString);
}
System.out.println("Invoice id: " + id + " | Grand Total = " + grandTotal);
}
}