-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocation.java
More file actions
142 lines (114 loc) · 3.39 KB
/
Location.java
File metadata and controls
142 lines (114 loc) · 3.39 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import java.util.Vector;
public class Location {
private String roomTitle;
private String roomDescription;
private String shortroomDescription;
private Vector<Exit> listExits;
private Vector<Item> listItems = new Vector<Item>();
private Vector<Container> listContainers = new Vector<Container>();
private Vector<CharacterObject> listCharacters = new Vector<CharacterObject>();
private Boolean hasEntered = false;
public Location() {
this.roomTitle = new String();
this.roomDescription = new String();
this.shortroomDescription = new String();
this.listExits = new Vector<Exit>();
}
public Location(String Title) {
this.roomTitle = Title;
this.roomDescription = new String();
this.shortroomDescription = new String();
this.listExits = new Vector<Exit>();
}
public Location(String Title, String Description) {
this.roomTitle = Title;
this.roomDescription = Description;
this.shortroomDescription = new String();
this.listExits = new Vector<Exit>();
}
public Location(String Title, String Description, String shortDescription) {
this.roomTitle = Title;
this.roomDescription = Description;
this.shortroomDescription = shortDescription;
this.listExits = new Vector<Exit>();
}
public String toString() {
return this.roomTitle;
}
public String getTitle() {
return this.roomTitle;
}
public void setTitle(String Title) {
this.roomTitle = Title;
}
public String getDescription() {
if(hasEntered) {
return this.shortroomDescription;
}
else
return this.roomDescription;
}
public void setDescription(String Description) {
this.roomDescription = Description;
}
public String getshortDescription() {
return this.shortroomDescription;
}
public void setShortDescription(String shortDesc) {
this.shortroomDescription = shortDesc;
}
public Vector<Exit> getExits() {
return (Vector<Exit>) this.listExits.clone();
}
public void addExit(Exit exit) {
this.listExits.addElement(exit);
}
public void removeExit(Exit exit){
if(this.listExits.contains(exit))
listExits.removeElement(exit);
}
public Vector<Item> getItems() {
return (Vector<Item>) this.listItems.clone();
}
public void addItem(Item item) {
this.listItems.addElement(item);
item.setLocation(this);
}
public void removeItem(Item item){
if(this.listItems.contains(item))
listItems.removeElement(item);
}
public Vector<Container> getContainers() {
return (Vector<Container>) this.listContainers.clone();
}
public void addContainer(Container container) {
this.listContainers.addElement(container);
}
public void removeContainer(Container container){
if(this.listContainers.contains(container))
listContainers.removeElement(container);
}
public Boolean getHasEntered() {
return this.hasEntered;
}
public void setHasEntered(Boolean Entered){
this.hasEntered = Entered;
}
public void addCharacter(CharacterObject person) {
listCharacters.add(person);
}
public Vector<CharacterObject> getCharacters() {
return (Vector<CharacterObject>) listCharacters;
}
public CharacterObject returnlastChar() {
return listCharacters.lastElement();
}
public Exit getExitAt(String dir) {
Exit toReturn = null;
for(int i = 0; i < this.listExits.size(); i++) {
if((listExits.elementAt(i).getDirection().equals(dir)) || (listExits.elementAt(i).getShortDirection().equals(dir)))
toReturn = listExits.elementAt(i);
}
return toReturn;
}
}