All pastes #441830 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-15 21:43 UTC
rendered paste body

public class Board{
	
	private Tile[][] board = null;
	private int curRow = 0;
	private int curCol = 0;
	
    /**
     * Create an empty Cesty game board with the given dimensions.
     * Parameters: 
     * numRows - the number of rows in the board.
     * numCols - the number of columns in the board.
     */
    public Board(int numRows, int numCols) throws Exception {
	    if ((numRows < 1) || (numCols < 1)) throw new Exception("Invalid parameters");
        Tile[][] board = new Tile[numRows][numCols];
    }

    public boolean play(Tile piece){
        board[curRow][curCol] = piece;
        return true;
    }
}

//it creates a board of whatever size bigger than 1x1, then on the first move:

	    	switch (getInput()) {
		    	case 1:
		    	gameBoard.play(new UpperRightTile()); break;
	    		case 2:
		    	gameBoard.play(new UpperLeftTile()); break;
		    	case 3:
		    	gameBoard.play(new CrossTile()); break;
	    	}