-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowsExporer.java
More file actions
120 lines (100 loc) · 3.86 KB
/
WindowsExporer.java
File metadata and controls
120 lines (100 loc) · 3.86 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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.util.NoSuchElementException;
//Here's only the Main class. The classes for the data structure implementation are deleted for author rights!
public class WindowsExplorer {
public static void main(String[] args) throws Exception {
int i, j, k;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String commands[] = new String[N];
for (i = 0; i < N; i++)
commands[i] = br.readLine();
br.close();
SLLTree<String> tree = new SLLTree<String>();
tree.makeRoot("c:");
// vasiot kod stoi ovde
String[] temp;
String command;
String namee;
SLLNode<String> opened = tree.root;
for (i = 0; i < N; i++) {
temp = commands[i].split(" ");
command = temp[0];
if (temp.length == 2) {
namee = temp[1];
SLLNode<String> jazol = new SLLNode<String>(namee);
if (command.equals("CREATE")) {
SLLNode<String> ttemp = opened.firstChild;
SLLNode<String> ttemposen = opened.firstChild;
int counter = 0;
while (ttemp != null) {
if (namee.compareTo(ttemp.element) > 0)
{
counter++;
ttemposen = ttemp;
}
ttemp = ttemp.sibling;
}
if (counter == 0)
{
tree.addChild(opened, namee);
}
else
{
SLLNode<String> nov = new SLLNode<String>(namee);
nov.sibling = ttemposen.sibling;
ttemposen.sibling = nov;
nov.parent = opened;
}
}
else if (command.equals("OPEN"))
{
SLLNode<String> ttemp = opened.firstChild;
while (ttemp != null)
{
if (ttemp.element.compareTo(namee) == 0)
opened = ttemp;
ttemp = ttemp.sibling;
}
}
else if (command.equals("DELETE"))
{
SLLNode<String> ttemp = opened.firstChild;
while (ttemp != null)
{
if (ttemp.element.equals(namee)) {
tree.remove(ttemp);
break;
}
ttemp = ttemp.sibling;
}
}
}
else
{
if (command.equals("BACK"))
{ opened = opened.parent;
}
else if (command.equals("PATH")) {
SLLNode<String> ttemp = opened;
String s = "\\";
while (ttemp != tree.root) {
s = ttemp.element + s;
s = "\\" + s;
ttemp = ttemp.parent;
}
System.out.print(tree.root.element);
System.out.println(s);
} else if (command.equals("PRINT"))
tree.printTree();
else
{
return;
}
}
}
}
}