-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlace.java
51 lines (40 loc) · 1.41 KB
/
Place.java
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
package Chimera.tech;
import java.io.*;
import java.util.*;
// You could point a gun to my head and ask me what the place and places classes did and I would tell you my last words
public class Place {
public final int placeID;
private final String desc;
private final Map<String, Integer> exits;
public Place(int placeID, String desc, Map<String, Integer> exits) {
this.placeID = placeID;
this.desc = desc;
if(exits != null) {
this.exits = new LinkedHashMap<String, Integer>(exits);
} else {
this.exits = new LinkedHashMap<String, Integer>();
}
this.exits.put("Q", 0);
}
public int getPlaceID() {
return placeID;
}
public String getDesc() {
return desc;
}
public String exitsIntoString() {
String exitList = "";
for (String exit : exits.keySet()) {
exitList = exitList + exit + ", ";
}
String exitFinal = exitList.substring(0, exitList.length()-2);
return exitFinal;
}
public Map<String, Integer> getExits() {
return new LinkedHashMap<String, Integer>(exits);
}
protected void addExit(String direction, int location) {
exits.put(direction, location);
}
// accessible within class or subclasses of package - make sure this doesn't get misused by other parts
}