public void displayInternal() { // TODO Auto-generated method stub for (int i = 0; i < rowmat; i++) { for (int j = 0; j < colmat; j++) { if (cellmat.thereIsMine(i, j)) { System.out.print("M"); } else { System.out.print(cellmat.getNumber(i, j)); } } System.out.println(); } }
MinesweeperImpl(int row, int col) { gameover = false; cellmat = new CellsMatImpl(); cellmat.init(row, col); this.rowmat = row; this.colmat = col; }
public void display() { // TODO Auto-generated method stub for (int i = 0; i < rowmat; i++) { for (int j = 0; j < colmat; j++) { if (cellmat.thereIsUncovered(i, j)) { if (cellmat.thereIsFlag(i, j)) { System.out.println("F"); } else { System.out.println(cellmat.getNumber(i, j)); } } else { System.out.print("X"); } } System.out.println(); } }
public boolean isWinningGame() { // TODO Auto-generated method stub int ContUncovered = 0; boolean GameOver = false; for (int i = 0; i < rowmat; i++) { for (int j = 0; j < colmat; j++) { if (cellmat.thereIsUncovered(i, j) || cellmat.thereIsFlag(i, j)) { ContUncovered++; } } } if (ContUncovered == cellmat.getNumberOfMines()) { GameOver = true; gameover = true; } return GameOver; }
public void uncover(int row, int col) { // TODO Auto-generated method stub if (!cellmat.thereIsUncovered(row, col)) { if (cellmat.thereIsMine(row, col)) { gameover = true; } else { if (cellmat.getNumber(row, col) == 0) { int[][] binmatrix = new int[rowmat][colmat]; for (int i = 0; i < rowmat; i++) { for (int j = 0; j < colmat; j++) { if (cellmat.thereIsMine(i, j)) { binmatrix[i][j] = 1; } else { binmatrix[i][j] = 0; } } } Set<Matrix2DCellPosition> mat2d; mat2d = MatrixUtils.cascade(binmatrix, row, col); for (Matrix2DCellPosition matrix2dCellPosition : mat2d) { cellmat.uncoverCell(matrix2dCellPosition.getRow(), matrix2dCellPosition.getColumn()); } } else { cellmat.uncoverCell(row, col); } } } }
public void clearFlag(int row, int col) { // TODO Auto-generated method stub if (cellmat.thereIsFlag(row, col)) { cellmat.ClearFlag(row, col); } }
public void flagAsMine(int row, int col) { // TODO Auto-generated method stub if (!cellmat.thereIsFlag(row, col)) { cellmat.setFlag(row, col); } }