-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFood.java
More file actions
30 lines (24 loc) · 696 Bytes
/
Copy pathFood.java
File metadata and controls
30 lines (24 loc) · 696 Bytes
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
public class Food extends Resource {
private String type; // e.g., "Pills", "Canned", etc.
// Inventory/Request constructor
public Food(String name, int amount, String type) {
super(name, amount);
this.type = type;
}
// Copy constructor (for inventory copy)
public Food(Food other) {
super(other.getName(), other.getAmount());
this.type = other.type;
}
@Override
public Resource copy() {
return new Food(this); // uses copy constructor
}
public String getType() {
return type;
}
@Override
public String toString() {
return getName() + " (" + type + ") x" + getAmount();
}
}