
/** 
 Program:    Safe Class
 Purpose:    demonstrates a Java Class and protections;
 @author     john@december.com
 @version    1.10; 21 Nov 95 
 Note:       converted to 1.00 beta
 */

class Safe {

   public    int     doorNumber   = 123;
   private   boolean locked       = true;
   private   int     combination  = 456;

   public boolean isLocked(){
      return(locked);
   }

   public void unLock(int thisCombination) {
      if (thisCombination == combination) unLock();
   }

   private void unLock() {
      locked = false;
   }

   private void setCombination(int setting) {
      combination = setting;
   }

   Safe () { }

   Safe (int door) {
      doorNumber = door;
      setCombination(doorNumber);  // this is the trick to cracking a safe
   }
}
