-
Notifications
You must be signed in to change notification settings - Fork 0
/
LSBSTApp.java
48 lines (42 loc) · 1.31 KB
/
LSBSTApp.java
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
import java.io.*;
import java.util.*;
public class LSBSTApp{
private static BinarySearchTree data;
private static int Count=0; //instrumentation
public static void main(String[] args)throws Exception{
data = new BinarySearchTree ();
try{
File file = new File("./Load_Shedding_All_Areas_Schedule_and_Map.clean.final.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
for (int i = 0; i<2976; i++){
if ( (st = br.readLine()) != null){
int index = st.indexOf("_", 2);
if (index == 4){
data.insert(new Loadshedding(st.substring(0,7), st.substring(7)));
}
if (index == 3){
data.insert(new Loadshedding(st.substring(0,6), st.substring(7)));
}
}
}
}
catch(Exception e){
}
if(args.length != 0){
printAreas(args[0],args[1],args[2]);
}
/*else{
printAllAreas();
}*/
// printNoOperations();
}
public static void printAreas(String stage, String day, String startTime){
if ((data.find(new Loadshedding(stage+"_"+day+"_"+startTime, null))!=null)){
System.out.println((data.find(new Loadshedding(stage+"_"+day+"_"+startTime, null)).toString()));
}
else{
System.out.println("Areas not found.");
}
}
}