A driver class, inputoutput class and numberValidator class. The user is to input a number 1-8 using a j-option pane popup box, if what is entered is not 1-8 an error message is supposed to display. If the number is 1-8 the rest of the code (not written here) is supposed to continue to run. I'm getting errors, anyone see where I'm wrong?
///Driver class (excludes package)////
public class Driver {
public static void main(String[] args) {
InputOutput inputoutput = new InputOutput();
inputoutput.displayMenu();
}
}
///InputOutput class (excludes package and import for JOptionPane)///
public class InputOutput {
public int displayMenu()
{
String stringChoice = JOptionPane.showInputDialog("Restaurant:\n"
+ "1. Pancakes: $10.00\n"
+ "2. Bananas: $1.00\n"
+ "3. Bread: $2.00\n");
if (numberValidator.isNumeric(stringChoice)){
choiceNumber = Integer.parseInt(stringChoice);
}
return choiceNumber;
}
///numberValidator class code (excludes package)///
public class numberValidator {
public boolean isNumeric(String str)
{
boolean valid = true;
String regex = "[1-8/.]*";
valid = str.matches(regex);
return valid;
}
}