Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Door {
- private String inscription;
- private boolean locked;
- private boolean closed;
- public Door(String c) {
- this.inscription = c;
- this.locked = true;
- this.closed = true;
- }
- public boolean isClosed() {
- return this.closed;
- }
- public boolean isLocked() {
- return this.locked;
- }
- public void open() {
- if (isClosed() && !isLocked())
- this.closed = true;
- else
- System.out.println(inscription + "is either open or locked");
- }
- public void close() {
- if (isClosed())
- System.out.println(inscription + " is closed");
- else
- this.closed = true;
- }
- public void lock() {
- if (isLocked())
- System.out.println(inscription + " is locked");
- else
- this.locked = true;
- }
- public void unlock() {
- if (!isLocked())
- System.out.println(inscription + " is unlocked");
- else {
- this.locked = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement