/** * Tester for the Answer of 2015 #2 where you need to * write the HiddenWord class, * including any necessary instance variables, * constructor, and the getHint method. * You may assume that the length of the guess is the same as the * length of the hidden word. * * @author Ethan * @version March 12, 2020 */ public class HiddenWordTester { public static void testGetHint(HiddenWord puzzle, String guess, String expected) { System.out.print("Guess: " + guess +"; "); System.out.println("Should return: " + expected ); String yourCode = puzzle.getHint(guess); System.out.print("\t\tYour Code: " + yourCode); String result = " Fail :("; if (expected.equals (yourCode) ) result = " Pass :)"; System.out.println(result+"\n"); } public static void main(String[] args) { HiddenWord puzzle = new HiddenWord("MOUSE"); System.out.println("Testing getHint Method with the HiddenWord \"MOUSE\" \n"); testGetHint(puzzle, "MOOSE", "MO+SE"); testGetHint(puzzle, "HORNS", "*O**+"); testGetHint(puzzle, "MAYOR", "M**+*"); testGetHint(puzzle, "HOUSE", "*OUSE"); testGetHint(puzzle, "MOURN", "MOU**"); testGetHint(puzzle, "APPLE", "****E"); testGetHint(puzzle, "MOUSE", "MOUSE"); System.out.println("Testing getHint Method with the HiddenWord \"HARPS\" \n"); puzzle = new HiddenWord("HARPS"); testGetHint(puzzle, "AAAAA", "+A+++"); testGetHint(puzzle, "HELLO", "H****"); testGetHint(puzzle, "HEART", "H*++*"); testGetHint(puzzle, "HARMS", "HAR*S"); testGetHint(puzzle, "HARPS", "HARPS"); } }