Created
November 1, 2012 19:48
-
-
Save ZachOrr/3995994 to your computer and use it in GitHub Desktop.
Emily Lockable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Lockable { | |
int key = 0; | |
boolean locked = false; | |
void setKey(int key) { | |
this.key = key; | |
} | |
void lock(int key) { | |
if(key == this.key) locked = true; | |
} | |
void unlock(int key) { | |
if(key == this.key) locked = false; | |
} | |
boolean locked() { | |
return this.locked; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bizarre, what is this for? Seems like a weird class. Why not just initiate it with a key, and then define lock() and unlock() without any arguments?