import java.util.*; import java.io.*; /** *
* This facade class is used to run the homework assignments. This is a console * application that accepts the name of the problem as a command line parameter * along with the problem-specific parameters. *
* ** Example of usage: * *
* java CPS170HW1 15 15.txt ** * Will run the A* algorithm for the 15 puzzle, reading the initial state from * the file "15.txt". * *
* java CPS170HW1 Superqueens 4 ** * Will run the A* algorithm for the Superqueens puzzle with 4 superqueens on a * 4x4 board. * * */ public class CPS170HW1 { /** * This is the entry point to this application. See the class description * for usage. * * @param args - * command line arguments. * @throws IOException * @throws NumberFormatException */ public static void main(String[] args) throws IOException, NumberFormatException { if (args.length < 1) { System.out .println("Please specify the name of the problem to solve."); return; } if (args[0].equals("15")) { if (args.length < 2) { System.out.println("Please specify the input file name."); return; } String filename = args[1]; AStar.run(FifteensNode.parseFromFile(filename)); } else if (args[0].equals("Superqueens")) { if (args.length < 2) { System.out.println("Please specify the number of queens."); return; } int nQueens = Integer.parseInt(args[1]); AStar.run(SuperqueensNode.createRootNode(nQueens)); } else { System.out.println("Unknown problem name: " + args[0]); } } }