Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LockClientDemoClass
  4. {
  5. public static void main(String [] args)
  6. {
  7. menuMethod();
  8. }
  9.  
  10. public static void menuMethod()
  11. {
  12. int x, y, z;
  13. Scanner sc = new Scanner(System.in);
  14. LockDataStructureClass nLock = new LockDataStructureClass();
  15.  
  16. while(true)
  17. {
  18. System.out.println("\nPick a letter from the list for"
  19. + " the lock simulator.");
  20. System.out.println(" A: Set a new lock combination ");
  21. System.out.println(" B: Closes lock");
  22. System.out.println(" C: Attempt opening lock ");
  23. System.out.println(" D: Lock Status ");
  24. System.out.println(" E: Check current number \n");
  25.  
  26. char menuLetter = sc.next().charAt(0);
  27. menuLetter = Character.toUpperCase(menuLetter);
  28.  
  29. switch(menuLetter)
  30. {
  31. case 'A':
  32. {
  33. System.out.println("\nSet the first number of lock combo.");
  34. x = sc.nextInt();
  35.  
  36. System.out.println("Set the second number of lock combo.");
  37. y = sc.nextInt();
  38.  
  39. System.out.println("Set the third number of lock combo.");
  40. z = sc.nextInt();
  41.  
  42. nLock.alter(x, y, z);
  43. break;
  44. }
  45.  
  46.  
  47. case 'B':
  48. {
  49. System.out.println("Click!");
  50. nLock.close();
  51. nLock.inquire(LockDataStructureClass.sealed);
  52. break;
  53. }
  54.  
  55. case 'C':
  56. {
  57. System.out.println("");
  58.  
  59. System.out.println("Put the first number of lock combo.");
  60. x = sc.nextInt();
  61.  
  62. System.out.println("Put the second number of lock combo.");
  63. y = sc.nextInt();
  64.  
  65. System.out.println("Put the third number of lock combo.");
  66. z = sc.nextInt();
  67.  
  68. nLock.attempt(x, y, z);
  69. break;
  70.  
  71. }
  72.  
  73. case 'D':
  74. {
  75. nLock.inquire(LockDataStructureClass.sealed);
  76. break;
  77. }
  78.  
  79. case 'E':
  80. {
  81. System.out.println("The top number is now: "
  82. + nLock.current());
  83. break;
  84. }
  85.  
  86. case 'X':
  87. {
  88. System.out.println("Exiting lock.");
  89. return;
  90. }
  91.  
  92. default:
  93. {
  94. System.out.println("\n*** Invalid choice! ***");
  95. System.out.println("Pick from A - E or X to quit.");
  96. break;
  97. }
  98. }
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement