-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
154 lines (121 loc) · 3.63 KB
/
Account.java
File metadata and controls
154 lines (121 loc) · 3.63 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
package shopping;
import java.util.ArrayList;
import java.util.Date;
public class Account {
protected String accountId;
protected String billingAddress;
protected boolean isClosed;
protected Date open;
protected Date closed;
protected int balance;
protected ShoppingCart shoppingCart;
protected ArrayList<Order> orders;
protected ArrayList<Payment> payments;
protected Customer customer;
protected int object_id;
public Account(int object_id, String accountId, String billingAddress,int balance) {
this.object_id = object_id;
this.balance = balance;
this.accountId = accountId;
this.billingAddress = billingAddress;
this.isClosed = false;
this.open = new Date();
this.orders = new ArrayList<>();
this.payments = new ArrayList<>();
}
public Customer getCustomer() {
return customer;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getBillingAddress() {
return billingAddress;
}
public void setBillingAddress(String billingAddress) {
this.billingAddress = billingAddress;
}
public boolean isClosed() {
return isClosed;
}
public void setClosed(boolean closed) {
isClosed = closed;
}
public Date getOpen() {
return open;
}
public void setOpen(Date open) {
this.open = open;
}
public Date getClosed() {
return closed;
}
public void setClosed(Date closed) {
this.closed = closed;
}
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
this.balance = balance;
}
public ArrayList<Order> getOrders() {
return orders;
}
public void setOrders(ArrayList<Order> orders) {
this.orders = orders;
}
public ArrayList<Payment> getPayments() {
return payments;
}
public void setPayments(ArrayList<Payment> payments) {
this.payments = payments;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
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 = "Account, id:" + accountId + ", Billing Address:" + billingAddress + ", Is Closed:" + isClosed + ", Opened:" + open
+ ", Closed:" + closed + ", Balance:" + balance + "\n";
String connected = "Connected to:" + customer.getClass().getSimpleName() + ", " + shoppingCart.getClass().getSimpleName();
if (orders.size() > 0){
String ords = "";
for (Order o : orders){
ords += o.getClass().getSimpleName() + " ";
}
connected += " " + ords;
}
if (payments.size() > 0){
String pays = "";
for (Payment p : payments){
pays += p.getClass().getSimpleName() + " ";
}
connected += " " + pays;
}
return fields + connected;
}
public void addPayment(Payment payment){
if (!payments.contains(payment))
payments.add(payment);
}
public void addOrder(Order order){
if (!orders.contains(order))
orders.add(order);
}
}