Android Open Source - Android-Minesweeper Cell






From Project

Back to project page Android-Minesweeper.

License

The source code is released under:

MIT License

If you think the Android project Android-Minesweeper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jigglesoft.minesweeper.game.board;
//from  w  ww  .jav a  2s.c om
import com.jigglesoft.minesweeper.game.board.Flags.Flag;


public class Cell {

  
  private boolean revaled = false;
  private Flag flag = Flag.NONE;
  
  private Cell[] neighbors = {};
  
  
  public void setNeighbors(Cell[] neighbors) {
    this.neighbors = neighbors;
  }
  
  public Cell[] getNeighbors() {
    return neighbors;
  }
  
  public int noOfNeighborIsBomb() {
    int noOfNeighborBombs = 0;
    for (Cell neighbor : neighbors) {
      if (neighbor.isBomb()) noOfNeighborBombs++;
    }
    return noOfNeighborBombs;
  }
  
  public boolean hasBombNeighbor() {
    return noOfNeighborIsBomb() > 0;
  }
  
  public void revealCell() {
    revaled = true;
  }
  
  public boolean isRevealed() {
    return revaled;
  }
  
  public boolean isBomb() {
    return false;
  }
  
  public void setFlag(Flag flag) {
    this.flag = flag;
  }
  
  public Flag getFlag() {
    return flag;
  }

  public boolean hasWarningFlag() {
    return flag == Flag.WARNING;
  }
  

}




Java Source Code List

com.jigglesoft.minesweeper.BoardAdapter.java
com.jigglesoft.minesweeper.MainActivity.java
com.jigglesoft.minesweeper.MinesweeperFragment.java
com.jigglesoft.minesweeper.SettingsActivity.java
com.jigglesoft.minesweeper.SettingsFragment.java
com.jigglesoft.minesweeper.SquareImageView.java
com.jigglesoft.minesweeper.game.MinesweeperGame.java
com.jigglesoft.minesweeper.game.board.Board.java
com.jigglesoft.minesweeper.game.board.BombCell.java
com.jigglesoft.minesweeper.game.board.Cell.java
com.jigglesoft.minesweeper.game.board.Flags.java
com.jigglesoft.minesweeper.game.exceptions.IllegalGameConstructionException.java