-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
73 lines (63 loc) · 2.86 KB
/
Main.java
File metadata and controls
73 lines (63 loc) · 2.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
import java.util.Scanner;
public class Main {
static boolean menuActive = true;
public static void main(String[] args)
{
// Clear console
System.out.print("\033[H\033[2J");
System.out.flush();
// Using SaveLoad, reads the contents in "options.txt" and updates options accordingly
SaveLoad.ReadOptions();
// Creates a scanner object for user input
Scanner scanner = new Scanner(System.in);
// MAIN MENU LOOP
while ( menuActive )
{
// Display menu
Menu.DisplayMenu();
// Create an int called userInput used for menu evaluation.
// If the input cannot be converted to an int, InputHandler stops evaluation
int userInput = InputHandler.ObtainIntInput(scanner, 1);
if ( 0 == userInput ) { // Quit program
menuActive = false;
} else if ( 1 == userInput ) { // Start game
Guesser.GameLoop(scanner, false);
} else if ( 2 == userInput ) { // Play missed questions
if ( Guesser.IsMissedEmpty() == true ){ // If none exist...
System.out.println("There are no missed equations yet!");
} else { // If they do exist
Guesser.GameLoop(scanner, true);
}
} else if ( 3 == userInput ) { // Go to settings menu
Settings(scanner);
} else if ( 10 == userInput ) { // Test equation display mode (DEBUG)
Equation demo_equation = new Equation();
demo_equation.DisplayEquation(false);;
} else {
System.out.println("Unacceptable input; please try again.");
}
}
// At the closure of the program, end the scanner object
scanner.close();
}
public static void Settings(Scanner scanner)
{
while ( true ) { // While in the settings menu
// Display settings, obtain user input
Menu.DisplaySettings();
int userInput = InputHandler.ObtainIntInput(scanner, 1);
if ( 0 == userInput ) { // Return to main menu
break;
} else {
if ( 1 == userInput ) { // Set new bounds using SetBounds function, save bounds to file
Equation.SetBounds(scanner);
SaveLoad.UpdateOptions(Equation.GetTopBound(), Equation.GetBottomBound(), Guesser.ReturnMissedEquations());
} else if ( 2 == userInput ) { // Clear missed equations, save empty array to file
Guesser.ResetMissedEquations();
SaveLoad.UpdateOptions(Equation.GetTopBound(), Equation.GetBottomBound(), Guesser.ReturnMissedEquations());
System.out.println("Missed equations deleted.");
}
}
}
}
}