-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.java
More file actions
75 lines (62 loc) · 2.41 KB
/
Copy pathQueue.java
File metadata and controls
75 lines (62 loc) · 2.41 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
package dashboard;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class Queue {
private static final String FILE_SEPARATOR = System.getProperty("file.separator");
public static void page() {
boolean continueSorting = true;
boolean unsort = true;
while (continueSorting) {
// Load error data from file
String path = getPath();
ErrorData errorData = new ErrorData();
errorData.load(path + FILE_SEPARATOR + "dashboard" + FILE_SEPARATOR + "files" + FILE_SEPARATOR + "errors.csv");
ErrorData[] errors = errorData.getErrors();
if (unsort == true) {
// Display the unsorted table
System.out.println("Error Data (Unsorted):\n");
ErrorData.displayTable(errors);
}
// Ask user for sorting options
System.out.println("\nSort Options:");
System.out.println("1. Sort by Last Update Time");
System.out.println("2. Sort by Status");
System.out.println("3. Exit to navigation");
System.out.print("Enter your choice (1, 2, or 3): ");
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
CodeUtil.clearScreen();
// Perform sorting based on user's choice:
switch (choice) {
case 1:
unsort = false;
ErrorData.sortByLastUpdateTime(errors);
break;
case 2:
unsort = false;
ErrorData.sortByStatus(errors);
break;
case 3:
continueSorting = false;
System.out.println("Exiting sorting...");
break;
default:
System.out.println("Invalid choice. No sorting applied.");
break;
}
// Display the sorted table
System.out.println("\nError Data (Sorted):\n");
ErrorData.displayTable(errors);
}
Navigation.navbar();
}
private static String getPath() {
try {
return new File(".").getCanonicalPath();
} catch (IOException e) {
System.out.println("Error: while getting the path of the program.");
return "";
}
}
}