-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileTree.java
More file actions
41 lines (31 loc) · 825 Bytes
/
FileTree.java
File metadata and controls
41 lines (31 loc) · 825 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
40
41
import java.util.*;
/**
* Creates a way to store the folders in a convenent way.
*/
class FileTree {
FileTree() {}
private String parent;
private ArrayList<String> children;
private int level = 0;
public void setParent(String parent_in){
parent = parent_in;
setLevel();
}
public String getParent(){ return parent; }
public void setChildren(ArrayList<String> children_in){ children = children_in; }
public ArrayList<String> getChildren(){ return children; }
public void setLevel(){
for (int i=0; i<parent.length(); i++){
if (parent.charAt(i) == '/'){
level++;
}
}
}
public int getLevel(){ return level; }
/*public static void main(String[] args){
String parent = "AC/ABC/HHAH/";
FileTree ft = new FileTree();
ft.setParent(parent);
System.out.println(ft.getLevel());
}*/
}