Question: You are to write java code called NumericKeypad class. The way this keypad should work is that when it is created, it will have two
You are to write java code called NumericKeypad class. The way this keypad should work is that when it is created, it will have two digit codes that are stored as Strings and a boolean variable that keeps track of the locks status locked or unlocked The first code is the unlock code. The second code is the administrative code that must be entered when changing the unlock code. When the pad is created, both codes are set to The NumericKeypad class should have a private method that will validate the entered code to make sure that it is digits
I have provided you with the tester program. I have put comments in the program to help you understand the operation of the keypad. This class is not writen the most efficient way. In this itteration of the program all print statements are in the tester class. No printing is done from the NumericKeypad class.
below is the tester:
public class KeypadTester
public static void mainString args
Call to the constructor
NumericKeypad myKeypad new NumericKeypad;
Call to the setAdminCode method using a bad value. All codes must be four digits
The first code is not four digits long
ifmyKeypadsetAdminCode
System.out.println
The admin code has been reset.";
else
System.out.println
There was a problem with the codes entered. ;
Correct call to the setAdminCode method
ifmyKeypadsetAdminCode
System.out.println
The admin code has been reset.";
else
System.out.println
There was a problem with the codes entered. ;
Call to the resetCode method using the wrong admin code
ifmyKeypadresetCode
System.out.println
The keypad code has been changed.";
else
System.out.println
There was an error resetting the code. No changes made. ;
Call to the resetCode using the right admin code
ifmyKeypadresetCode
System.out.println
The keypad code has been changed.";
else
System.out.println
There was an error resetting the code. No changes made. ;
Call to the lock method
myKeypad.lock;
System.out.println
The keypad is now locked.";
Call to the unlock method using the wrong code. This is the admin code not the unlock code.
ifmyKeypadunlock
System.out.println
The keypad is now unlocked.";
else
System.out.println
The incorrect code wase entered. Keypad is still locked. ;
Call to the unlock method using the right unlock code.
ifmyKeypadunlock
System.out.println
The keypad is now unlocked.";
else
System.out.println
The incorrect code wase entered. Keypad is still locked. ;
below is also the test case that the program will need to pass:
Therewasaproblemwiththecodesentered
Theadmincodehasbeenreset
TherewasanerrorresettingthecodeNochangesmade
Thekeypadcodehasbeenchanged
Thekeypadisnowlocked
TheincorrectcodewaseenteredKeypadisstilllocked
Thekeypadisnowunlocked
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
