Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LockClientDemoClass
- {
- public static void main(String [] args)
- {
- menuMethod();
- }
- public static void menuMethod()
- {
- int x, y, z;
- Scanner sc = new Scanner(System.in);
- LockDataStructureClass nLock = new LockDataStructureClass();
- while(true)
- {
- System.out.println("\nPick a letter from the list for"
- + " the lock simulator.");
- System.out.println(" A: Set a new lock combination ");
- System.out.println(" B: Closes lock");
- System.out.println(" C: Attempt opening lock ");
- System.out.println(" D: Lock Status ");
- System.out.println(" E: Check current number \n");
- char menuLetter = sc.next().charAt(0);
- menuLetter = Character.toUpperCase(menuLetter);
- switch(menuLetter)
- {
- case 'A':
- {
- System.out.println("\nSet the first number of lock combo.");
- x = sc.nextInt();
- System.out.println("Set the second number of lock combo.");
- y = sc.nextInt();
- System.out.println("Set the third number of lock combo.");
- z = sc.nextInt();
- nLock.alter(x, y, z);
- break;
- }
- case 'B':
- {
- System.out.println("Click!");
- nLock.close();
- nLock.inquire(LockDataStructureClass.sealed);
- break;
- }
- case 'C':
- {
- System.out.println("");
- System.out.println("Put the first number of lock combo.");
- x = sc.nextInt();
- System.out.println("Put the second number of lock combo.");
- y = sc.nextInt();
- System.out.println("Put the third number of lock combo.");
- z = sc.nextInt();
- nLock.attempt(x, y, z);
- break;
- }
- case 'D':
- {
- nLock.inquire(LockDataStructureClass.sealed);
- break;
- }
- case 'E':
- {
- System.out.println("The top number is now: "
- + nLock.current());
- break;
- }
- case 'X':
- {
- System.out.println("Exiting lock.");
- return;
- }
- default:
- {
- System.out.println("\n*** Invalid choice! ***");
- System.out.println("Pick from A - E or X to quit.");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement