<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/* Class with main program that is used to check out
   assignment 2.
*/

public class TrivialApplication {

    public static void main(String args[]) {
        LockFirm lf= new LockFirm();   // lf contains the one LockFirm that we deal with
	
        System.out.println("Empty lockfirm going to be printed");
        System.out.println(lf);
        System.out.println();
	
        LockComboSerial lcs1= lf.buyLock();  // lcs1 and lcs2 are the the first two
        LockComboSerial lcs2= lf.buyLock();  // locks bought --each contains the lock,
	                                     // its combination, and its serial number
	
        System.out.println("lockfirm with two sold locks going to be printed");
        System.out.println(lf);
        System.out.println();
	
        Lock lock1= lcs1.getLock();   // the lock in lsc1
        Lock lock2= lcs2.getLock();   // the lock in lcs2

        // Change the guesses on Locks lock1 and lock2 so that lock1 is unlocked
        // and lock2 is still locked. To do this (for debugging only), we use the
        // fact that we know how class LockFirm generates the combinations --the
        // natural numbers 0, 1, 2, 3, 4, 5, ... are used, in order.  Later, we
        // could change LockFirm to use random numbers for the combinations
	lock1.setFirstGuess(0);
	lock1.setSecondGuess(1);
	lock1.setThirdGuess(2);
	lock2.setFirstGuess(0);
	lock2.setSecondGuess(1);
	lock2.setThirdGuess(2);
	
        System.out.println("lockfirm with two sold locks going to be printed");
        System.out.println(lf);
        System.out.println();
	    	    
        System.out.println("lock1 is unlocked: " + lock1.isUnlocked());
        System.out.println("lock2 is unlocked: " + lock2.isUnlocked());

        // Try to get the combinations for locks lock1 and lock2. It should
        // find the combination for lock1, but not for lock2, because the wrong
        // serial number is used.
	Triple combo1Found= lf.whatsTheCombo(lock1, lcs1.getSerialNumber());
	Triple combo2Found= lf.whatsTheCombo(lock2, lcs1.getSerialNumber());
	
        System.out.println("Combination for lock1 found: " + combo1Found);
        System.out.println("Combination for lock2 found: " + combo2Found);
        System.out.println();
	
        System.out.println( "end of this test of assignment 2" );
    }
}
</pre></body></html>