-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.java
More file actions
136 lines (114 loc) · 2.69 KB
/
Item.java
File metadata and controls
136 lines (114 loc) · 2.69 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
public class Item {
private String Name;
private String Description;
private Exit keyTo = new Exit();
private Location currLocation = new Location();
private Boolean inInventory = false;
private Container inContainer = new Container();
private Boolean inC = false;
public Item(){
Name = new String();
Description = new String();
keyTo = null;
currLocation = null;
}
public Item(String Name){
this.Name = Name;
this.Description = new String();
keyTo = null;
currLocation = null;
}
public Item(String Name, String Description){
this.Name = Name;
this.Description = Description;
keyTo = null;
currLocation = null;
}
public Item(String Name, Location isIn){
this.Name = Name;
this.currLocation = isIn;
isIn.addItem(this);
keyTo = null;
}
public Item(String Name, String Description, Location isIn){
this.Name = Name;
this.Description = Description;
this.currLocation = isIn;
isIn.addItem(this);
keyTo = null;
}
public Item(String Name, Location isIn, Exit keyTo){
this.Name = Name;
this.currLocation = isIn;
isIn.addItem(this);
this.keyTo = keyTo;
}
public Item(String Name, String Description, Location isIn, Exit keyTo){
this.Name = Name;
this.Description = Description;
this.currLocation = isIn;
isIn.addItem(this);
this.keyTo = keyTo;
keyTo.setIsLocked(true);
keyTo.setKey(this);
}
public String toString() {
return this.Name;
}
public String getName(){
return this.Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getDescription(){
return this.Description;
}
public void setDescription(String Description) {
this.Description = Description;
}
public Location getLocation(){
return this.currLocation;
}
public void setLocation(Location isIn) {
this.currLocation = isIn;
//if(isIn != null)
//isIn.addItem(this);
}
public Exit getIsKeyTo() {
return this.keyTo;
}
public void setKeyTo(Exit isKeyTo) {
this.keyTo = isKeyTo;
isKeyTo.setIsLocked(true);
isKeyTo.setKey(this);
}
public Boolean isitintheInventory(){
return this.inInventory;
}
public void setinInventory(Boolean inInventory) {
this.inInventory = inInventory;
this.currLocation = null;
}
public void putinContainer(Container container){
if(this.getLocation() != null) {
if(container.getLocation() == this.getLocation()) {
this.inContainer = container;
//container.addItem(this);
}
}
else {
this.inContainer = container;
this.setLocation(container.getLocation());
container.addItem(this);
}
inC = true;
}
public void removefromContainer(){
inContainer.removeItem(this);
inC = false;
}
public Boolean isitinaContainer() {
return inC;
}
}