Question
- Write pre and postcondition statements for the methods specified in the Lock interface (shown below): public interface Lock { public boolean locked(); public void
- Write pre and postcondition statements for the methods specified in the Lock interface (shown below):
public interface Lock {
public boolean locked();
public void unlock(String key);
public void setKey(int code, String newKey); }
- Write a class that implements the Lock interface. Your class should include a set of instance variables, a set of constructors, and must implement the methods specified in the interface. You must also include a simple main method to demonstrate each of your methods in action.
instance variables: ____________________________________________________
constructor(s): _______________________________________________________
locked: _____________________________________________________________
unlock: _____________________________________________________________
setKey: ______________________________________________________________
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started