/** ****************************************************************************** * HOMEWORK: 15-111 ****************************************************************************** * A medley of recursive methods ****************************************************************************** * * This is the main driver. This is only for your own testing purposes; you do not need to turn this in. * * * @author * @date *****************************************************************************/ import java.util.*; public class MedleyDriver { public static void main(String[] args) { //PLEASE ADD MORE TEST CASES TO MAKE SURE YOUR IMPLEMENTATIONS WORKS! //Phonewords System.out.println("\n\n**********\n\n"); System.out.println("Phonewords"); Phonewords pw = new Phonewords(); Set words = pw.generateAllPhoneWords("234"); for(String str : words) { System.out.print(str + " "); } /* * Expected output (in some order): afi afh afg aei aeh aeg adi adh adg bdg bdi bdh bei bfg bfh bfi beh beg cdg cdi cfg cfi cfh ceg cdh ceh cei */ System.out.println("\n\n**********\n\n"); //Maze System.out.println("Maze"); int[][] grid = {{1, 1, 1, 1, 1}, {1, 0, 0, 0, 0}, {1, 1, 1, 1, 1}, {0, 1, 0, 0, 1}, {1, 1, 1, 0, 1}}; Maze m = new Maze(grid); int[][] solved = m.solveMaze(); m.printMaze(solved); /* * Expected output (if you implemented printMaze) * * 1 1 1 1 * 0 0 0 0 * * * * * 0 1 0 0 * 1 1 1 0 * */ System.out.println("\n\n**********\n\n"); //Flat World System.out.println("Flat World"); boolean[][] world = {{true, true, false, false, false, false, false, true, false, false}, {false, true, false, false, false, false, false, true, false, false}, {false, false, false, false, false, false, true, true, false, false}, {false, true, false, false, true, true, true, false, false, false}, {false, true, true, false, true, false, true, false, true, false}, {false, true, true, false, true, true, true, true, true, true}, {true, false, false, false, false, false, false, false, true, false}, {false, false, false, false, false, false, false, false, true, false}, {false, false, false, true, true, true, false, false, true, false}, {false, false, false, false, false, true, false, false, true, false}}; boolean[][] world2 = {{true,false,true}, {true,false,true}, {true,false,true}, {true,false,true}}; FlatWorld f = new FlatWorld(); System.out.print("\nThe Number of Organisms is "); System.out.println(f.numOrganisms(world)); //Expected: 5 System.out.print("\nThe Number of Organisms is "); System.out.println(f.numOrganisms(world2)); //Expected: 2 System.out.println("\n\n**********\n\n"); //Arrangements System.out.println("Arrangements"); Arrangements a = new Arrangements(); Set set = new HashSet(); set.add(new Integer(1)); set.add(new Integer(2)); set.add(new Integer(3)); Set orderings = a.generateAllArrangements(set); for(int[] ordering : orderings) { System.out.println(Arrays.toString(ordering)); } /* * Expected (in some order): * * [2, 1, 3] * [3, 1, 2] * [1, 2, 3] * [3, 2, 1] * [1, 3, 2] * [2, 3, 1] * */ System.out.println("\n\n**********\n\n"); //Pattern System.out.println("Pattern"); Pattern p = new Pattern(); p.pattern(8); /* * Expected output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ } }