-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShoppingCart.java
More file actions
86 lines (67 loc) · 1.95 KB
/
ShoppingCart.java
File metadata and controls
86 lines (67 loc) · 1.95 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package shopping;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ShoppingCart {
private Date created;
private WebUser webUser;
private Account account;
private ArrayList<LineItem> lineItems;
private int object_id;
public ShoppingCart(int object_id, Date created) {
this.created = created;
this.object_id = object_id;
lineItems = new ArrayList<>();
}
public void addLineItemToCart(LineItem lineItem){
if(!lineItems.contains(lineItem)){
addLineItemToCart(lineItem);
}
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public WebUser getWebUser() {
return webUser;
}
public void setWebUser(WebUser webUser) {
this.webUser = webUser;
}
public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
public ArrayList<LineItem> getLineItems() {
return lineItems;
}
public void setLineItems(ArrayList<LineItem> lineItems) {
this.lineItems = lineItems;
}
public void addLineItem(LineItem lineItem){
this.lineItems.add(lineItem);
}
public int getObjectId() {
return object_id;
}
public void setObjectId(int object_id) {
this.object_id = object_id;
}
@Override
public String toString() {
String fields = "Shopping Cart, Created:" + created + "\n";
String Connected = "Connected to:" + webUser.getClass().getSimpleName() + ", " + account.getClass().getSimpleName();
if (lineItems.size() > 0){
String lines = "";
for (LineItem li : lineItems){
lines += li.getClass().getSimpleName() + ",";
}
Connected += ", " + lines;
}
return fields + Connected;
}
}