-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainer.java
More file actions
90 lines (71 loc) · 1.87 KB
/
Container.java
File metadata and controls
90 lines (71 loc) · 1.87 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
import java.util.Vector;
public class Container {
private Location isHere;
private Vector<Item> ItemsInHere = new Vector<Item>();;
private Vector<Container> hasContainers = new Vector<Container>();
private String Description = new String();;
private String Name;
public Container(){
isHere = new Location();
ItemsInHere = new Vector<Item>();
}
public Container(String Name) {
this.Name = Name;
isHere = new Location();
}
public Container(String Name, Location here) {
this.Name = Name;
this.isHere = here;
}
public String toString(){
return this.Name;
}
public Location getLocation() {
return isHere;
}
public void setLocation(Location here) {
this.isHere = here;
}
public String getName() {
return this.Name;
}
public void setName(String Name){
this.Name = Name;
}
public String getDescription() {
return Description;
}
public void setDescription(String Description) {
this.Description = Description;
}
public Vector<Item> getItems() {
return (Vector<Item>) this.ItemsInHere.clone();
}
public void addItem(Item item) {
if(item != null) {
this.ItemsInHere.addElement(item);
//item.putinContainer(this);
}
}
public void removeItem(Item item){
if(this.ItemsInHere.contains(item))
ItemsInHere.removeElement(item);
}
public Vector<Container> getContainers() {
return (Vector<Container>) this.hasContainers.clone();
}
public void addContainer(Container container) {
if((container.getLocation() == null) || (container.getLocation() == this.getLocation()))
this.hasContainers.addElement(container);
}
public void removeContainer(Container container){
if(this.hasContainers.contains(container))
hasContainers.removeElement(container);
}
public Boolean hasSomething() {
if((!(this.ItemsInHere.isEmpty())) || (!(this.hasContainers.isEmpty())))
return true;
else
return false;
}
}