advance scanner past bad input on error
This commit is contained in:
@@ -50,7 +50,8 @@ public class AlgorithmTester{
|
||||
}
|
||||
*/
|
||||
} 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];
|
||||
|
||||
Reference in New Issue
Block a user