-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoryElement.java
More file actions
56 lines (47 loc) · 1.18 KB
/
Copy pathStoryElement.java
File metadata and controls
56 lines (47 loc) · 1.18 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
package storyelements;
/**
*
* @author etienne
*/
public abstract class StoryElement {
private static int aNumberOfGameObjects = 0;
private int aID;
protected StoryElement() {
aNumberOfGameObjects++;
aID = aNumberOfGameObjects;
}
public int getID() {
return aID;
}
/**
* Returns a string "n" if the following word starts with a vowel.
* @param noun
* @return
*/
public static String addN(String word) {
char first = word.toLowerCase().charAt(0);
if (first == 'a' || first == 'e' || first == 'i' || first == 'o'
|| first == 'u') {
return "n";
} else {
return "";
}
}
@Override
public boolean equals(Object o) {
if (o == null) return false;
if (o == this) return true;
if (!(o instanceof StoryElement)) return false;
StoryElement g = (StoryElement) o;
if (g.aID == this.aID){
return true;
}
else return false;
}
@Override
public int hashCode() {
int hash = 3;
hash = 29 * hash + this.aID;
return hash;
}
}