-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
42 lines (35 loc) · 1.22 KB
/
Order.java
File metadata and controls
42 lines (35 loc) · 1.22 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
package cafeteria;
import java.time.LocalTime;
class Order {
private Customer customer;
private String[] itemsOrdered;
private double totalAmount;
private String orderID;
private String orderTime;
public Order(Customer customer, String[] itemsOrdered, double totalAmount) {
this.customer = customer;
this.itemsOrdered = itemsOrdered;
this.totalAmount = totalAmount;
this.orderID = "ORD" + System.currentTimeMillis(); // Generate unique ID
this.orderTime = LocalTime.now().toString(); // Used LocalTime correctly
}
public void printOrderDetails() {
System.out.println("Order Details for " + customer.getName());
for (String item : itemsOrdered) {
System.out.println(item);
}
System.out.println("Total Amount: ETB " + totalAmount);
System.out.println("Order ID: " + orderID);
System.out.println("Order Time: " + orderTime);
System.out.println("********************************************");
}
public double getTotalAmount() {
return totalAmount;
}
public String getOrderID() {
return orderID;
}
public String getOrderTime() {
return orderTime;
}
}