-
Notifications
You must be signed in to change notification settings - Fork 1
/
Item
57 lines (50 loc) · 1.2 KB
/
Item
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
mport java.util.Objects;
public class Item {
private final String name;
private final int weight;
private final int gold;
public Item(){
this();
}
public Item(String name, int weight ,int gold){
this.name = name;
this.weight = weight;
this.gold = gold;
}
public int getGold(){
return gold;
}
public String getName(){
return name;
}
public int getWeight(){
return weight;
}
public void examine(){
System.out.println("Name: " + name + ", Weight: " + weight);
}
@Override
public int hashCode() {
int hash = 7;
hash = 73 * hash + Objects.hashCode(this.name);
hash = 73 * hash + this.weight;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Item other = (Item) obj;
if (!Objects.equals(this.name, other.name)) {
return false;
}
if (this.weight != other.weight) {
return false;
}
return true;
}
}