-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
112 lines (88 loc) · 2.38 KB
/
Product.java
File metadata and controls
112 lines (88 loc) · 2.38 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package shopping;
import java.util.ArrayList;
import java.util.List;
public class Product {
private String id;
private String name;
private Supplier supplier;
private PremiumAccount seller;
private List<LineItem> lineItems;
private int price;
private int inStock;
private int object_id;
public Product(int object_id, String id, String name) {
this.id = id;
this.name = name;
this.lineItems = new ArrayList<>();
this.object_id = object_id;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public Supplier getSupplier() {
return supplier;
}
public PremiumAccount getSeller() {
return seller;
}
public List<LineItem> getLineItems() {
return lineItems;
}
public void addLineItem(LineItem lineItem) {
if(lineItem != null){
this.lineItems.add(lineItem);
}
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getInStock() {
return inStock;
}
public void setInStock(int inStock) {
this.inStock = inStock;
}
public void setSeller(PremiumAccount seller) {
this.seller = seller;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setSupplier(Supplier supplier) {
this.supplier = supplier;
}
public void setLineItems(List<LineItem> lineItems) {
this.lineItems = lineItems;
}
public int getObjectId() {
return object_id;
}
public void setObjectId(int object_id) {
this.object_id = object_id;
}
@Override
public String toString() {
String fields = "Product, id:" + id + ", Name:" + name + ", inStock" + inStock + "\n";
String Connected = "Connected to:" + supplier.getClass().getSimpleName();
if (lineItems.size() > 0){
String lines = "";
for (LineItem li : lineItems){
lines += li.getClass().getSimpleName() + " ";
}
Connected += " " + lines;
}
if (seller != null){
Connected+= ", Seller:" + seller.getClass().getSimpleName();
}
return fields + Connected;
}
}