Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. private String[] optionList;
  2.  
  3. private String openingMessage;
  4.  
  5. private String topPrompt;
  6.  
  7. private String closingMessage;
  8.  
  9. private String bottomPrompt;
  10.  
  11.  
  12. public Menu(String[] options)
  13. {
  14. optionList = options;
  15. openingMessage = "";
  16. topPrompt = "Choose an option:";
  17. closingMessage = "";
  18. bottomPrompt = "Enter an option number:";
  19. }
  20.  
  21. public Menu()
  22. {
  23. optionList = null;
  24. openingMessage = "";
  25. topPrompt = "";
  26. closingMessage = "";
  27. bottomPrompt = "";
  28. }
  29.  
  30. public boolean isEmpty(String[] options)
  31. {
  32. if (options == null)
  33. {
  34. return true;
  35. }
  36.  
  37. return false;
  38. }
  39.  
  40. public int length(String[] options)
  41. {
  42. return options.length;
  43. }
  44.  
  45. public String toString()
  46. {
  47. return (topPrompt + "n" + "?->" + " " + bottomPrompt);
  48. }
  49.  
  50. public static void main(String[] args)
  51. {
  52. String[] drink_options = {"Water", "Soda pop", "Beer"};
  53.  
  54. Menu drinkMenu = new Menu(drink_options);
  55.  
  56. System.out.println(drinkMenu);
  57. //System.out.println(drinkMenu.isEmpty(drink_options));
  58. //System.out.println(drinkMenu.length(drink_options));
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement