-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.java
More file actions
39 lines (30 loc) · 854 Bytes
/
Copy pathDirectory.java
File metadata and controls
39 lines (30 loc) · 854 Bytes
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
package Files;
import java.util.HashMap;
import java.util.ArrayList;
public class Directory extends Node{
private HashMap<String, Node> children;
private Directory parent;
public Directory(String name) {
super(name);
children = new HashMap<>();
parent = null;
}
public void remove(String name) {
this.children.remove(name);
}
public void setParent(Directory parent) {
this.parent = parent;
}
public Directory getParent() {
return this.parent;
}
public void addChild(Node node) {
children.put(node.getName(), node);
}
public Node getChild(String name) {
return children.get(name);
}
public ArrayList<String> getChildren() {
return new ArrayList<>(children.keySet());
}
}