Repository navigation
Expand file tree
/
Copy pathTransaction.java
More file actions
68 lines (52 loc) · 1.66 KB
/
Copy pathTransaction.java
File metadata and controls
68 lines (52 loc) · 1.66 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.ArrayList;
public class Transaction {
public final ArrayList<LineItem> lineItems;
private int customerID;
private String customerName;
private String LineItem;
private int i;
public Transaction (int customerID, String customerName){
this.customerID = customerID;
this.customerName = customerName;
this.lineItems = new ArrayList<>();
}
public int getcustomerID(){
return customerID;
}
public void setcustomerID(int customerID){
this.customerID = customerID;
}
public String getcustomerName(){
return customerName;
}
public void setcustomerName(String customerName){
this.customerName = customerName;
}
public String addLineItem(){
lineItems.add(new LineItem("Colgate Toothpaste", 2,2.99));
lineItems.add(new LineItem("Bounty Paper Towels", 1, 1.49));
lineItems.add(new LineItem("Kleenex Tissue", 1, 2.49));
//System.out.println(lineItems);
return ("colgate not found");
}
public String updateItem()
{
return null;
}
public double getTotalPrice(){
double totalPrice = 0;
for (int i =0;i<lineItems.size(); i++){
LineItem item = lineItems.get(i);
totalPrice = totalPrice + item.getTotalPrice();
}
return totalPrice;
}
public String getLineItem(){
return LineItem;
}
@Override
public String toString()
{
return ("Customer ID:" + this.customerID + "\n" + "Customer Name" + this.customerName );
}
}