/** * Board.java * CIS 260 * David Klick * 2012-03-09 * * This class implements a grid to hold the cells of * a maze. * * @author Dave Klick * @version 1.0 2012-03-09 */ import java.util.ArrayList; class Board { private int rows, cols; private Cell startCell = null, endCell = null; private static int MAX_ROWS = 100, MAX_COLS = 100; public Cell[][] cell = null; public ArrayList getConnectedNeighbors(Cell c) { // ***** ***** // ***** THIS METHOD MUST BE IMPLEMENTED ***** // ***** ***** } public ArrayList getUnvisitedConnectedNeighbors(Cell c) { // ***** ***** // ***** THIS METHOD MUST BE IMPLEMENTED ***** // ***** ***** } public ArrayList getUnvisitedNeighbors(Cell c) { // ***** ***** // ***** THIS METHOD MUST BE IMPLEMENTED ***** // ***** ***** } public Board(int r, int c) { if (r<1 || r>MAX_ROWS) { throw new IllegalArgumentException("Rows value out of range: " + r + " should be in range 0 < rows <= " + MAX_ROWS); } if (c<1 || c>MAX_COLS) { throw new IllegalArgumentException("Cols value out of range: " + c + " should be in range 0 < cols <= " + MAX_COLS); } rows = r; cols = c; cell = new Cell[rows][cols]; for (int i=0; i=rows) { throw new IllegalArgumentException("Rows value out of range: " + r + " should be in range 0 <= rows < " + rows); } if (c<0 || c>=cols) { throw new IllegalArgumentException("Cols value out of range: " + c + " should be in range 0 <= cols < " + cols); } return cell[r][c]; } public Cell getAdjacentCell(Cell c, Direction d) { // return null if attempt to go past maze boundary if (c.hasEdge(d)) return null; return cell[c.getRow()+d.deltaRow][c.getCol()+d.deltaCol]; } public void connect(Cell cell1, Direction d) { cell1.clearWall(d); getAdjacentCell(cell1, d).clearWall(d.opposite()); } public int getRows() { return rows; } public int getCols() { return cols; } public void clearVisited() { for (int r=0; r