-
Notifications
You must be signed in to change notification settings - Fork 0
/
LSArrayApp.java
58 lines (50 loc) · 1.53 KB
/
LSArrayApp.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
49
50
51
52
53
54
55
56
57
58
import java.io.*;
import java.util.*;
public class LSArrayApp{
private static Loadshedding[] data;
private static int Count=0; //instrumentation
public static void main(String[] args)throws Exception{
data = new Loadshedding[2976];
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(" ");
data[i] = new Loadshedding(st.substring(0,index), st.substring(index));
}
}
}
catch(Exception e){
}
if(args.length == 3){
printAreas(args[0],args[1],args[2]);
}
else if (args.length == 0){
printAllAreas();
}
else{
System.out.println("Incorrect Parameters!");
}
printNoOperations();
}
public static void printAreas(String stage, String day, String startTime){
for (int i=0; i<2976; i++){
Count++; // instrumentation
if ((data[i].Details()).equals(stage+"_"+day+"_"+startTime)){
System.out.println("Area(s) to be loadshedded is/are:"+data[i].Area());
return;
}
}
System.out.println("Areas not found.");
}
public static void printAllAreas(){
for (int i=0; i<2976; i++){
System.out.println(data[i].toString());
}
}
public static void printNoOperations(){
System.out.println("The number of comparisons is: " + Count);
}
}