Repository navigation
Expand file tree
/
Copy pathOrder.java
More file actions
96 lines (81 loc) · 2.3 KB
/
Copy pathOrder.java
File metadata and controls
96 lines (81 loc) · 2.3 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
package product;
import java.util.Date;
import java.util.Scanner;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class Order{
private Date dateReceived;
private double price;
private int orderID;
private Product[] wantedItems;
private OrderLine[] wantedQuantity;
public Order() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
dateReceived = new Date();
dateFormat.format(dateReceived);
price = 0;
orderID = 0;
wantedItems = new Product[10];
wantedQuantity = new OrderLine[10];
int counter = 0;
while (counter < 10) {
wantedItems[counter] = new Product();
counter++;
}
counter = 0;
while (counter < 10) {
wantedQuantity[counter] = new OrderLine();
counter++;
}
}
// setters
public void set_dateReceived(Date new_dateReceived) {
dateReceived = new_dateReceived;
}
public void set_price(double new_price) {
price = new_price;
}
public void set_orderID(int new_orderID) {
orderID = new_orderID;
}
// getters
public Date get_dateReceived() {
return dateReceived;
}
public double get_price() {
return price;
}
public int get_orderID() {
return orderID;
}
public Product[] items() {
return wantedItems;
}
public OrderLine[] quantity() {
return wantedQuantity;
}
// methods required
public Date getDateReceived() { //////////// ?????????????
return dateReceived;
}
public double calculatePrice(ProductCatalogue catalg) {
System.out.println("Order recipt:");
System.out.println("Date order recieved: " + dateReceived);
int counterLoop = 0;
int counterItems = 0;
while (counterLoop < 10) {
price = price + (wantedQuantity[counterLoop].getQuantiy() * catalg.getProducts()[counterLoop].getPrice3());
if (wantedQuantity[counterLoop].getQuantiy() > 0) {
System.out.println("*****************" );
System.out.println("item " + ++counterItems + ":" );
System.out.println("Name: " + catalg.getProducts()[counterLoop].getName3());
System.out.println("Price: " + catalg.getProducts()[counterLoop].getPrice3());
System.out.println("product ID: " + catalg.getProducts()[counterLoop].getProductID3());
System.out.println("Quentity: " + wantedQuantity[counterLoop].getQuantiy());
System.out.println("*****************" );
}
counterLoop++;
}
return price;
}
}