Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public class Door {
  2.     private String inscription;
  3.     private boolean locked;
  4.     private boolean closed;
  5.  
  6.     public Door(String c) {
  7.         this.inscription = c;
  8.         this.locked = true;
  9.         this.closed = true;
  10.     }
  11.  
  12.     public boolean isClosed() {
  13.         return this.closed;
  14.     }
  15.  
  16.     public boolean isLocked() {
  17.         return this.locked;
  18.     }
  19.  
  20.     public void open() {
  21.         if (isClosed() && !isLocked())
  22.             this.closed = true;
  23.         else
  24.             System.out.println(inscription + "is either open or locked");
  25.     }
  26.  
  27.     public void close() {
  28.         if (isClosed())
  29.             System.out.println(inscription + " is closed");
  30.         else
  31.             this.closed = true;
  32.     }
  33.  
  34.     public void lock() {
  35.         if (isLocked())
  36.             System.out.println(inscription + " is locked");
  37.         else
  38.             this.locked = true;
  39.     }
  40.  
  41.     public void unlock() {
  42.         if (!isLocked())
  43.             System.out.println(inscription + " is unlocked");
  44.         else {
  45.             this.locked = false;
  46.         }
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement