/** * Maze1.java * CIS 260 * David Klick * 2012-03-09 * * This class creates a maze. * * @author Dave Klick * @version 1.0 2012-03-09 */ import java.util.ArrayList; import java.util.Collections; import java.util.Random; import java.util.Stack; public class Maze1 { private Random rnd = new Random(); private static int ROWS = 30, COLS = 30; private Board b = null; private Cell startCell = null, endCell = null; public Maze1() { b = new Board(ROWS, COLS); Random rnd = new Random(); // ***** ***** // ***** THIS SECTION MUST BE IMPLEMENTED ***** // ***** ***** System.out.println("All cells on board visited: " + allCellsVisited()); System.out.println("All boundaries correct: " + allBoundariesCorrect()); System.out.println("All cells reachable: " + allCellsReachable()); b.setStartCell(b.getCell(0, rnd.nextInt(COLS))); b.setEndCell(b.getCell(ROWS-1, rnd.nextInt(COLS))); System.out.println(b); } public static void main(String[] args) { if (args.length > 2 || (args.length == 1 && (args[0].matches("--?([hH]|[hH][eE][lL][pP])")))) { System.err.println("Usage: java Maze1 [rows [columns]]"); System.exit(1); } try { if (args.length > 1) COLS = Integer.parseInt(args[1]); if (args.length > 0) ROWS = Integer.parseInt(args[0]); } catch (NumberFormatException e) { System.err.println("Illegal integer argument"); System.exit(2); } new Maze1(); } /** * Method used to test a maze to make sure all cells * have been visited. * * @return true if all cells have been visited, otherwise false * */ private boolean allCellsVisited() { for (int r=0; r lst = new ArrayList(); int min, v = 0; while (changed) { changed = false; for (r=0; r