January 3rd, 2018
Classwork:
Programming Project 5.6:
Design a Java interface called Lockable that includes the following methods: setKey, lock, unlock, and locked. The setKey, lock, and unlock methods take an integer parameter that represents the key. The setKey method establishes the key. The lock and unlock methods lock and unlock the object, but only if the key passed in is correct. The locked method returns a boolean that indicates whether or not the object is locked. A Lockable object represents an object whose regular methods are protected: if the object is locked, the methods cannot be invoked; if it is unlocked, they can be invoked. Redesign and implement a version of the Coin class from Chapter 4 so that it is Lockable.
Include a driver.
Homework:
Programming Project 5.7:
Redesign and implement a version of the Account class from Chapter 4 so that it is Lockable as defined by Programming Project 5.6.
Include a driver.