-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource.java
More file actions
33 lines (23 loc) · 803 Bytes
/
resource.java
File metadata and controls
33 lines (23 loc) · 803 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
31
32
33
/*
AP CS A Final Project
Alex Williams and [redacted for privacy]
05/01/2026
*/
public class resource extends item {
private int amount; // all resources have an amount, whether that be 1 stack of wood or a thousand units of food
public resource(String name, int startAmount){
// call gameitem constructor to set the name
super(name); // call the parent class
this.amount = startAmount;
}
public void add(int quantity) {
this.amount += quantity;
}
public int getAmount() { // simple getter to return the maount of the item in the user's inventory
return amount;
}
public void setAmount (int amount){
this.amount = amount;
}
}
// this just extends item, required to meet the "inheritance" req on the rubric