-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.java
More file actions
88 lines (70 loc) · 1.97 KB
/
Item.java
File metadata and controls
88 lines (70 loc) · 1.97 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
public abstract class Item implements Cloneable {
protected String itemID;
protected String itemName;
protected String itemDesc;
protected String itemType;
protected int itemValue;
protected int maxStack;
protected int currentStack = 1; //default 1
//constructor
public Item(String itemID, String itemName, String itemDesc, int itemValue, int maxStack) {
this.itemID = itemID;
this.itemName = itemName;
this.itemDesc = itemDesc;
this.itemValue = itemValue;
this.maxStack = maxStack;
}
@Override
public Item clone() {
try {
return (Item) super.clone(); // shallow copy is fine for primitives/Strings
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
//getters
public String getItemID(){
return itemID;
}
public String getItemName() {
return itemName;
}
public String getItemDesc() {
return itemDesc;
}
public int getItemValue() {
return itemValue;
}
public String getItemType() {
return itemType;
}
public int getMaxStack(){
return maxStack;
}
public int getCurrentStack(){
return currentStack;
}
public void setMaxStack(int maxStack) {
this.maxStack = maxStack;
}
public void setCurrentStack(int currentStack) {
this.currentStack = currentStack;
}
public boolean isEquipable(){
return false;
}
public boolean isConsumable(){
return false;
}
public boolean isUseable(){
return false;
}
public void use() {
System.out.println(itemName + "cannot be used.");
}
@Override
public String toString() {
return this.getItemName(); // or any property you want to display
}
}//end class