/** Program: SpyGame Class for application Purpose: demonstrates features of Safe class; @author john@december.com @version 1.10; 21 Nov 95 Note: converted to 1.00 beta Output: Which safe is this? 123 Is the safe locked? true Is 999 the combination? true Changing the door number ... Now the door is number: 555 Is the safe locked? true However, you can crack your own safe ... Is my safe locked? true My safe has door number 999 Unlocking safe with combination as doorNumber... Is my safe locked now? false */ class SpyGame { public static void main (String args[]) { System.out.println("SpyGame application..."); Safe theSafe = new Safe(); System.out.println("Which safe is this? " + theSafe.doorNumber); System.out.println("Is the safe locked? " + theSafe.isLocked()); /* Try to unlock the safe with a guessed combination of 999: */ theSafe.unLock(999); System.out.println("Is 999 the combination? " + theSafe.isLocked()); /* This wont' work: theSafe.unLock(); Gives compiler error: "Method void unLock() in class Safe is not accessible from class SpyGame." */ /* How about stealing the combination? Reference to this won't work: theSafe.combination; Gives compiler error: "Variable combination in class Safe not accessible from class SpyGame." */ /* How about resetting the safe's lock to a known combination? This won't work: theSafe.setCombination(999); Gives compiler error: "Method void setCombination(int) in class Safe is not accessible from class SpyGame." */ /* How about defacing the door's number? */ System.out.println("Changing the door number ..."); theSafe.doorNumber = 555; System.out.println("Now the door is number: " + theSafe.doorNumber); theSafe.unLock(theSafe.doorNumber); System.out.println("Is the safe locked? " + theSafe.isLocked()); System.out.println("However, you can crack your own safe ..."); Safe mySafe = new Safe(999); System.out.println("Is my safe locked? " + mySafe.isLocked()); System.out.println("My safe has door number " + mySafe.doorNumber); System.out.println("Unlocking safe with combination as doorNumber..."); mySafe.unLock(mySafe.doorNumber); System.out.println("Is my safe locked now? " + mySafe.isLocked()); } }