/** * A tile on a minesweeper board. * * @author John Paxton * @version 1.0 */ public class Tile { /** * Class constructor. */ Tile () { mine = false; guessed = false; surroundingMines = 0; } /** * Writer method. * * @param surroundingMines The number of mines surrounding this tile. */ public void setSurroundingMines (int surroundingMines) { this.surroundingMines = surroundingMines; } /** * Reader method. * * @return An integer that shows the number of surrounding mines. */ public int getSurroundingMines () { return surroundingMines; } public void setMine () { mine = true; } public boolean getMine () { return mine; } public void setGuessed () { guessed = true; } public boolean getGuessed () { return guessed; } public String getPrintString() { // if (!guessed) // { // return " "; // } if (mine) { return "*"; } else { return Integer.toString(surroundingMines); } } private boolean mine; // whether the tile contains a mine private boolean guessed; // whether the tile has been guessed private int surroundingMines; // the number of surrounding mines }