/** * A tile on a minesweeper board. * * @author John Paxton * @version 1.1 (January 21, 2004) */ 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; } /** * Writer method. */ public void setMine () { mine = true; } /** * Reader method. * * @return A boolean that indicates if a mine is located in this Tile. */ public boolean getMine () { return mine; } /** * Writer method. */ public void setGuessed () { guessed = true; } /** * Reader method. * * @return A boolean that indicates if this Tile has been guessed. */ public boolean getGuessed () { return guessed; } /** * General method. * * @return A string that contains the print representation of * what is located in the Tile. */ 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 }