-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineItem.java
More file actions
77 lines (60 loc) · 1.67 KB
/
LineItem.java
File metadata and controls
77 lines (60 loc) · 1.67 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
package shopping;
public class LineItem {
private int quantity;
private int price;
private Product product;
private ShoppingCart shoppingCart;
private Order order;
private int object_id;
public LineItem(int object_id, int quantity) {
this.quantity = quantity;
this.object_id = object_id;
}
public int getQuantity() {
return quantity;
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public void setPrice(){
if (this.product != null){
price = product.getPrice() * this.quantity;
}
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public ShoppingCart getShoppingCart() {
return shoppingCart;
}
public void setShoppingCart(ShoppingCart shoppingCart) {
this.shoppingCart = shoppingCart;
}
public int getObjectId() {
return object_id;
}
public void setObjectId(int object_id) {
this.object_id = object_id;
}
@Override
public String toString() {
String fields = "Line Item, Quantity:" + quantity + ", Price:" + price + "\n";
String Connected = product.getClass().getSimpleName() + ", " + shoppingCart.getClass().getSimpleName() + ", " + order.getClass().getSimpleName();
return fields+Connected;
}
}