This program creates 2 methods for convenience: menu() and binaryQ(). The menu method accepts several strings as its parameters. The first of the strings is the question to be displayed at the top of the menu. The following strings are the menu choices. For instance, if you call Confirmer.menu("What is your favorite fruit?","Apple","Orange","Banana");
the program will print the following:
What is your favorite fruit?
1) Apple
2) Orange
3) Banana
Enter selection number:
The binaryQ method accepts a single string as a parameter, representing the question. Then it asks the user to answer yes or no. Capitalization of the answer will not affect the code. If the user answers with a word that begins with y or n, the computer will read it as yes or no -- this way, "yea", "yup" and "yes" are all evaluated the same way. Of course, if you answer "Yetti," the computer will still evaluate that as an affirmative answer. If the answer is yes, the method returns true; if the answer is no the method returns false.
Neither method will crash from invalid input -- instead they will simply request valid input, and will loop until valid input is provided.