Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following file in Java: /** A simulated lock with digit buttons. */ public class Lock { private int combination = 1729; private int

Complete the following file in Java:

/** A simulated lock with digit buttons. */ public class Lock { private int combination = 1729; private int input;

/** Simulates a digit button push. @param button a digit 0 ... 9 */ public void push(int button) { . . . } /** Simulates a push of the open button. @return true if the lock opened */ public boolean open() { . . . } }

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 1 and 7, causing input to be 17, and now pushes 9, how can you set input to 179?

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 had been entered.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago