-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugMenuProcessor.java
More file actions
53 lines (47 loc) · 2.09 KB
/
DebugMenuProcessor.java
File metadata and controls
53 lines (47 loc) · 2.09 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
package ie.atu.sw;
import java.util.Scanner;
/**
* Handles the user input for enabling or disabling debug mode
*
* For debug mode, is intended, possibility to print and check in console
* data from Map and Set in order to verify if loading has been done
* correctly
*/
public class DebugMenuProcessor {
/**
* Processes user input to determine if debug mode should be enabled
*
* Prompts the user until they provide a valid response ('y' or 'n')
*
* <ul>
* <li>(y) - debug enable</li>
* <li>(n) - debug skipped</li>
* </ul>
*
* @param scanner capture user input
* @return A boolean value
*/
public boolean processDebugRequested(Scanner scanner) { //Big O = O(1)
while (true) { // Loop until a valid input is received
System.out.println(ConsoleColour.RED);
System.out.println("Would you like to enable debug mode? In debug mode, you can:");
System.out.println("* Display a specific number of lines from the word embedding map");
System.out.println("* Display a specific number of words from the Google-1000 word set");
System.out.println("* View the input sentence to be analyzed");
System.out.println("");
System.out.println("y - enable debug mode");
System.out.println("n - skip debug mode");
System.out.print(ConsoleColour.BLACK_BOLD_BRIGHT);
System.out.println("Select Option [y-n]>");
System.out.print("Pick an option: ");
String choice = scanner.nextLine().trim().toLowerCase(); // Read user input, trim whitespace, and convert to lowercase
if ("y".equals(choice)) { // If the user enters 'y', return true
return true;
} else if ("n".equals(choice)) { // If the user enters 'n', return false
return false;
} else {
System.out.println("Invalid input. Please enter 'y' for yes or 'n' for no."); // Prompt for valid input
}
}
}
}