Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // get the difficulty level as a character
  2. // Input: no input, but this method listens to users' keyboard input
  3. // Output: char 'e', 'i', or 'h'
  4. public static char difficulty() {
  5. char level;
  6.  
  7. while(true) {
  8. System.out.println("Enter your difficulty level:");
  9. Scanner keyboard = new Scanner(System.in);
  10. String input = keyboard.nextLine().toLowerCase();
  11.  
  12. try {
  13. if (validation(input) == true) {
  14. level = getLevel(input);
  15. return level;
  16. } else {
  17. System.out.println("Your input is invalid. "
  18. ."Please re-enter your difficulty level:");
  19. }
  20. } catch (NumberFormatException nFE){
  21. System.out.println("Your input is invalid. "
  22. ."Please re-enter your difficulty level:");
  23. }
  24. }
  25. }
  26.  
  27. // validate the input
  28. // Input: Users' input as a string
  29. // Output: true or false
  30. private static boolean validation(String str) {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement