-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocation.java
More file actions
99 lines (76 loc) · 2.42 KB
/
Location.java
File metadata and controls
99 lines (76 loc) · 2.42 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
89
90
91
92
93
94
95
96
97
98
99
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
class Location extends Entity {
private ArrayList<Artifact> artifacts = new ArrayList<>();
private ArrayList<Furniture> furnitureList = new ArrayList<>();
private ArrayList<Path> PathList = new ArrayList<>();
private ArrayList<Characters> CharactersHere = new ArrayList<>();
Location(String name, String description) {
super(name, description);
}
ArrayList<Artifact> getArtifacts() {
return artifacts;
}
ArrayList<Furniture> getFurnitureList() {
return furnitureList;
}
ArrayList<Characters> getCharactersHere() {
return CharactersHere;
}
void setArtifacts(Artifact a) {
artifacts.add(a);
}
void setFurnitureList(Furniture f) {
furnitureList.add(f);
}
void setPathList(Path p) {
PathList.add(p);
}
void setCharactersHere(Characters c) {
CharactersHere.add(c);
}
String getPaths() {
StringBuilder availablePaths = new StringBuilder("Your available paths are: ");
if (PathList.size() == 0) {
return "No available paths";
} else {
for (Path p : PathList) {
availablePaths.append(p.getEnd());
availablePaths.append(", ");
}
}
return availablePaths.toString();
}
Artifact getArtifact(String name) {
for(Artifact a : artifacts) {
if(a.getName().equals(name)) {
return a;
}
}
return null;
}
void addPlayer(Player p) {
CharactersHere.add(p);
}
void lookAround(BufferedWriter out) throws IOException {
out.write("Artifacts:\n");
for (Artifact a: artifacts) {
out.write("--Name-- " + a.getName() + "\n");
out.write("--Description-- " + a.getDescription() + "\n");
}
out.write("");
out.write("Furniture:\n");
for(Furniture f: furnitureList) {
out.write("--Name-- " + f.getName() + "\n");
out.write("--Description-- " + f.getDescription() + "\n");
}
out.write("\n");
out.write("Characters:\n");
for(Characters c: CharactersHere) {
out.write("--Name-- " + c.getName() + "\n");
out.write("--Description-- " + c.getDescription() + "\n");
}
out.write("\n");
}
}