-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
93 lines (75 loc) · 2.4 KB
/
Order.java
File metadata and controls
93 lines (75 loc) · 2.4 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
import java.util.Date;
public class Order {
private OrderDetail orderDetail;
private ShippingInfo shippingInfo;
private int orderId;
private int customerId;
private int shippingId;
private String customerName;
private String dateOrderCreated;
private String dateOrderShipped;
private boolean isNewOrder;
private boolean isProcessedOrder;
private boolean isCancelledOrder;
Order(int orderId, int customerId, String customerName, int shippingId, int [] productId, String [] productName, double [] unitCost) {
this.orderDetail = new OrderDetail(orderId, productId, productName, unitCost);
this.shippingInfo = new ShippingInfo(shippingId);
this.orderId = orderId;
this.customerId = customerId;
this.shippingId = shippingId;
this.customerName = customerName;
Date date = new Date();
this.dateOrderCreated = date.toString();
this.isNewOrder = true;
}
// ShippingInfo Methods
public String getShippingInfo() {
return shippingInfo.getShippingInfo();
}
public void setShippingCost(double shippingCost) {
shippingInfo.setShippingCost(shippingCost);
}
public void setShippingRegionId(int shippingRegionId) {
shippingInfo.setShippingRegionId(shippingRegionId);
}
// OrderDeatil Methods
public String getOrderDetails() {
String orderInfo = orderDetail.getOrderDetails() +
"\nCustomer: " + customerName +
"\n" + getOrderStatus() +
"\nDate Order Created: " + dateOrderCreated;
if (dateOrderShipped != null) orderInfo += "\nDate Order Shipped: " + dateOrderShipped;
return orderInfo;
}
// Order Methods
public int getOrderId() {
return orderId;
}
public String getOrderCreateDate() {
return dateOrderShipped;
}
public String getOrderShippingDate() {
return dateOrderShipped;
}
public void setOrderShippingDate() {
Date date = new Date();
this.dateOrderShipped = date.toString();
}
public void setProcessOrder() {
this.isNewOrder = false;
this.isProcessedOrder = true;
this.isCancelledOrder = false;
}
public void setCancelOrder() {
this.isNewOrder = false;
this.isProcessedOrder = false;
this.isCancelledOrder = true;
}
public String getOrderStatus() {
String orderStatusString = "";
if (true == isNewOrder) orderStatusString = "Order has been created!";
if (true == isProcessedOrder) orderStatusString = "Order is being processed!";
if (true == isCancelledOrder) orderStatusString = "Order has been cancelled!";
return orderStatusString;
}
}