-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuItem.java
More file actions
31 lines (26 loc) · 1.04 KB
/
Copy pathMenuItem.java
File metadata and controls
31 lines (26 loc) · 1.04 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
package java_assign2;
enum PaymentStatus { PENDING, SUCCESS, FAILED }
enum DeliveryStatus { CREATED, DISPATCHED, PICKED_UP, DELIVERED }
class MenuItem {
private int id;
private String name;
private double price;
private boolean available;
private int stock;
public MenuItem(int id, String name, double price, boolean available, int stock) {
this.id = id;
this.name = name;
this.price = price;
this.available = available;
this.stock = stock;
}
public boolean isAvailable() { return available && stock > 0; }
public void setAvailability(boolean avail) { this.available = avail; }
public double getPrice() { return price; }
public String getName() { return name; }
public void updateStock(int change) { this.stock += change; }
public int getId() { return id; }
public int getStock() { return stock; }
@Override
public String toString() { return name + " - ₹" + price + " (" + (isAvailable() ? "Available" : "Unavailable") + ")"; }
}