diff --git a/Sorting/AlgorithmTester.java b/Sorting/AlgorithmTester.java index c42ee30..07e4102 100644 --- a/Sorting/AlgorithmTester.java +++ b/Sorting/AlgorithmTester.java @@ -23,34 +23,35 @@ public class AlgorithmTester{ System.out.println("2) Sort a file of random numbers"); System.out.println("0) Exit"); try{ - input = sc.nextInt(); - //Using the new switch syntax introduced in JDK 13 - //this is a switch expression (lambda expression) rather than a switch statement - switch(input){ - case 1 -> makeFile(); - case 2 -> sortFile(); - case 0 -> quit=true; - default -> System.out.println("Invalid input"); - } - /* - non-lambda expresstion version looks like this - switch(input){ - case 1: - makeFile(); - break; - case 2: - sortFiler(); - break; - case 0: - quit=true; - break; - default: - System.out.println("Invalid input"); - break; - } - */ + input = sc.nextInt(); + //Using the new switch syntax introduced in JDK 13 + //this is a switch expression (lambda expression) rather than a switch statement + switch(input){ + case 1 -> makeFile(); + case 2 -> sortFile(); + case 0 -> quit=true; + default -> System.out.println("Invalid input"); + } + /* + non-lambda expresstion version looks like this + switch(input){ + case 1: + makeFile(); + break; + case 2: + sortFiler(); + break; + case 0: + quit=true; + break; + default: + System.out.println("Invalid input"); + break; + } + */ } catch(InputMismatchException ex){ - System.out.println("Invalid input"); + System.out.println("Invalid input exception"); + sc.next(); } } sc.close(); @@ -73,7 +74,8 @@ public class AlgorithmTester{ var randomMaker = new RandomNumberFileMaker(filename, count, min, max); randomMaker.writeFile(); } catch(InputMismatchException ex){ - System.out.println("Invalid input"); + System.out.println("Invalid input."); + sc.next(); } } @@ -111,6 +113,7 @@ public class AlgorithmTester{ } }catch(InputMismatchException ex){ System.out.println("Invalid input"); + sc.next(); } } try{ @@ -125,6 +128,7 @@ public class AlgorithmTester{ } }catch(InputMismatchException ex){ System.out.println("Invalid input, defaulting to no"); + sc.next(); } boolean bubble=sortingAlgoChoices[0]; boolean selection=sortingAlgoChoices[1];