class Robot extends Object120 { String id; String shape; boolean isTransformed; boolean isEvil; // constructor -- call 'super' (voodoo!) Robot( String i, String s, boolean t, boolean e ) { super(i,s,t,e); } /** Return a description of a Robot's current form. * @param bot The Robot to describe. * @return a description of a Robot's current form. */ static String currentForm( Robot bot ) { if (bot.isTransformed == true) { return bot.shape; } else { return "Tall 'bot"; } } static void testRobots() { Robot r1 = new Robot("WX4-G", "Corvette", true, false); Robot r2 = new Robot("AB0-A", "Mack Truck", false, true); System.out.println("Start testing"); testEqualStrings( currentForm(r1), "Corvette" ); testEqualStrings( currentForm(r2), "Tall 'bot" ); testEqualStrings( currentForm( new Robot("AB0-A", "phone", true, true) ), "phone" ); } /** Will two robots battle each other, given the chance? * @param bot1 The first Robot. * @param bot2 The second Robot. * @return true iff the two robots will battle. * Two robots battle if they are different evil-ness. * [Alternate: two evil robots battle as well!] */ static boolean willBattle( Robot bot1, Robot bot2 ) { return true; } /** Which of two robots is cooler? * @param bot1 The first Robot. * @param bot2 The second Robot. * @return Either bot1 or bot2, depening on who is cooler. * A robot with a *shorter* transformed-shape description is cooler; * in case of ties, the evil one is cooler. * */ static Robot coolerOf( Robot bot1, Robot bot2 ) { return bot1; } /** Make a new, evil copy of a given Robot. * @param aBot The Robot to make an evil copy of. * @return a new, evil copy of `aBot`. * (Evil copies have the original's serial number but * with a '-E' concatenated; they are always evil; * they have the same disguise and transformation status. */ static Robot evilCopy( Robot aBot ) { return aBot; } /** If two booleans aren't equal, print an error message. * Intended for use as a test-helper. * @param act The actual boolean returned by a test call. * @param exp The expected boolean to be returned by a test call. */ static void testEqualBools(boolean act, boolean exp) { if (act==exp) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } /** If two Robots aren't equal, print an error message. * Intended for use as a test-helper. * @param act The actual Robot returned by a test call. * @param exp The expected Robot to be returned by a test call. */ static void testEqualRobots(Robot act, Robot exp) { if (equals(act,exp)) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } /** If two Strings aren't equal, print an error message. * Intended for use as a test-helper. * @param act The actual String returned by a test call. * @param exp The expected String to be returned by a test call. */ static void testEqualStrings(String act, String exp) { if (equals(act,exp)) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } }