Create a Lockable Java interface with the following methods: setKey, lock, unlock, and locked. The setKey, lock, and unlock methods all accept an integer parameter representing the key. The key is created using the setKey method. The lock and unlock methods lock and unlock the object, but only if the key supplied is valid. The locked method returns a boolean indicating whether the object is locked or not. A Lockable object is one whose normal methods are protected: The methods cannot be invoked if the object is locked; they may be invoked if it is unlocked. Redesign and construct a Lockable version of the Coin class from Chapter 5.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question

Create a Lockable Java interface with the following methods: setKey, lock, unlock, and locked. The setKey, lock, and unlock methods all accept an integer parameter representing the key. The key is created using the setKey method. The lock and unlock methods lock and unlock the object, but only if the key supplied is valid. The locked method returns a boolean indicating whether the object is locked or not. A Lockable object is one whose normal methods are protected: The methods cannot be invoked if the object is locked; they may be invoked if it is unlocked. Redesign and construct a Lockable version of the Coin class from Chapter 5.

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT