-
Notifications
You must be signed in to change notification settings - Fork 0
/
collectable.pde
38 lines (33 loc) · 902 Bytes
/
collectable.pde
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
class Collectable {
private String name;
private String gameObjectImageFile;
public PImage image;
//Could be expanded to add an amount, for example
public Collectable(String name, String gameObjectImageFile) {
this.name = name;
this.gameObjectImageFile = gameObjectImageFile;
image = loadImage(gameObjectImageFile);
}
public String getName() {
return name;
}
public String getGameObjectImageFile() {
return gameObjectImageFile;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}
Collectable otherCollectable = (Collectable) obj;
return otherCollectable.getName().equals(this.name);
}
@Override
public int hashCode() {
final int prime = 13;
return prime * this.name.hashCode();
}
}