All pastes #373854 Raw Edit

MikeH

public text v1 · immutable
#373854 ·published 2007-02-27 01:37 UTC
rendered paste body
import BookDigitByDigit.*;

public class LockablePassageway{
  
  private Passageway p;
  private CombinationLock lock;
  
  public LockablePassageway(Room room1, Room room2){
    p = new Passageway(room1, room2);
  }
  
  public boolean isUnlocked(){
    return lock.isOpen();
  }
  
  public void lock(int combo){
    lock = new CombinationLock(combo);
    lock.close();
  }
  
  public void unlock(int combo_digit){
    lock.enter(combo_digit);
    if (lock.isOpen()) System.out.println("The door is unlocked");
    else System.out.println("The door is locked");
  }
  
  public Room otherRoom(Room currentRoom){
    return p.otherRoom(currentRoom);
  }
}