-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
156 lines (123 loc) · 3.66 KB
/
Order.java
File metadata and controls
156 lines (123 loc) · 3.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package shopping;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
public class Order {
private String number;
private Date ordered;
private Date shipped;
private Address ship_to;
private OrderStatus status;
private float total;
private Account account;
private ArrayList<LineItem> lineItems;
private ArrayList<Payment> payments;
private int object_id;
public Order(int object_id, String number, Date ordered, Date shipped, Address ship_to, float total) {
this.number = number;
this.ordered = ordered;
this.shipped = shipped;
this.ship_to = ship_to;
this.status = OrderStatus.NEW;
this.total = total;
lineItems = new ArrayList<LineItem>();
payments = new ArrayList<Payment>();
this.object_id = object_id;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public Date getOrdered() {
return ordered;
}
public void setOrdered(Date ordered) {
this.ordered = ordered;
}
public Date getShipped() {
return shipped;
}
public void setShipped(Date shipped) {
this.shipped = shipped;
}
public Address getShip_to() {
return ship_to;
}
public void setShip_to(Address ship_to) {
this.ship_to = ship_to;
}
public OrderStatus getStatus() {
return status;
}
public void setStatus(OrderStatus status) {
this.status = status;
}
public float getTotal() {
return total;
}
public void setTotal(float total) {
this.total = total;
}
public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
public void addLineItem(LineItem lineItem){
if (!lineItems.contains(lineItem))
lineItems.add(lineItem);
}
public void removeItem(LineItem lineItem){
if (lineItems.contains(lineItem))
lineItems.remove(lineItem);
}
public void addPayment(Payment payment){
if (!payments.contains(payment))
payments.add(payment);
}
public void removePayment(Payment payment){
if (payments.contains(payment))
payments.remove(payment);
}
public ArrayList<LineItem> getLineItems() {
return lineItems;
}
public void setLineItems(ArrayList<LineItem> lineItems) {
this.lineItems = lineItems;
}
public ArrayList<Payment> getPayments() {
return payments;
}
public void setPayments(ArrayList<Payment> payments) {
this.payments = payments;
}
public int getObjectId() {
return object_id;
}
public void setObjectId(int object_id) {
this.object_id = object_id;
}
@Override
public String toString() {
String fields = "Order, " + "orderNumber:" + number + ", ordered:" + ordered + ", shipped:" + shipped + ", ship_to:" + ship_to + ", status:" + status.name() + ", total:" + total + "\n";
String connected = "Connected to:" + account.getClass().getSimpleName();
if (lineItems.size() > 0){
String lines = "";
for (LineItem li : lineItems){
lines += li.getClass().getSimpleName() + " ";
}
connected += " " + lines;
}
if (payments.size() > 0){
String pays = "";
for (Payment p : payments){
pays += p.getClass().getSimpleName() + " ";
}
connected += " " + pays;
}
return fields + connected;
}
}