Question: 1 4 . 5 . 1 : Implement a class that simulates a lock with numerical buttons. 5 4 1 6 6 6 . 3
: Implement a class that simulates a lock with numerical buttons.
qxzqy
Implement a class Lock that simulates a lock with numerical buttons.
Image of a touch tone phone keypad with numbers to and star, and pound
The push method simulates the push of a numeric button with value to
The open method simulates the push of the key that causes the lock to open, provided that the right combination was entered. For now, the configuration is hardwired as You will see in another section how to change it
As the data representation, use an integer containing the digits that have been entered up to this point. You will need to figure out how to update that number. For example, if the user had previously pushed and causing input to be and now pushes how can you set input to
In the open method, return true if the lock would have been opened, false otherwise. Clicking that button resets the entered keys, whether or not the correct combination has been entered.
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
