Android Open Source - FindtheMines Tile






From Project

Back to project page FindtheMines.

License

The source code is released under:

MIT License

If you think the Android project FindtheMines 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 findtheminecore;
/*from   ww w.  j a  va2  s.  c  om*/
import java.util.ArrayList;


public class Tile {

  private boolean isMine;
  private boolean isSelected;
  private boolean isMarked;
  int value;
  private boolean isHidden;
  
  public Tile(){
    super();
    this.isMine = false;
    this.isMarked = false;
    this.isSelected = false;
    this.isHidden = true;
    this.value = 0;
  }

  public Tile(TileType type) {
    super();
    this.isHidden = true;
    switch(type){
    case MINE:
      this.isMine = true;
      this.value = 1;
      break;
    case MARKED:
      this.mark();
      break;
    case SELECTED:
      this.select();
      break;
    default:
      break;
    }
  }

  public boolean isMarked() {
    return isMarked;
  }

  public void setMarked(boolean isMarked) {
    this.isMarked = isMarked;
  }



  public boolean isSelected() {
    return isSelected;
  }



  public void setSelected(boolean isSelected) {
    this.isSelected = isSelected;
    this.isHidden = false;
  }
  

  public boolean select(){
    if (!isMarked){
      if(isSelected){
        return false;
      }else{
        this.isHidden = false;
        return isSelected = true;
      }
    }else{
      return false;
    }
  }

  public boolean isMine() {
    return isMine;
  }



  public void setMine(boolean isMine) {
    this.isMine = isMine;
  }
  
  public int getValue() {
    return value;
  }



  public void setValue(int value) {
    // no negative values allowed
    if (value>=0){
      this.value = value;
    }
    
  }

  public void mark() {
    if (!isSelected){
      this.isMarked = true;
      this.isHidden = false;
    }
    
  }

  public void removeMark() {
    this.isMarked = false;
    this.isHidden = true;
    
  }

  public void addValueBy1() {
    value++;
    
  }

  public boolean isExploded() {
    return (isSelected && isMine);
  }

  public boolean isHidden() {
    return isHidden;
  }

  public void reveal() {
    isHidden = false;
    
  }

  public void clear() {
    this.isMine = false;
    this.isMarked = false;
    this.isSelected = false;
    this.isHidden = true;
    this.value = 0;
    
  }

  public void unMark() {
    this.isMarked = false;
    
  }

  public ArrayList<String> toStringArray() {
    ArrayList<String> tags = new ArrayList<String>();
    if (isSelected){
      tags.add("isSelected");
    }
    if (isMarked){
      tags.add("isMarked");
    }
    if (isMine){
      tags.add("isMined");
    }
    if (isExploded()){
      tags.add("isExploded");
    }
    if (tags.size()==0){
      tags.add("isEmpty");
    }
    return tags;  
  }


}




Java Source Code List

com.stealthness.findthemines.ImageAdapter.java
com.stealthness.findthemines.MainActivity.java
com.stealthness.findthemines.SplashScreen.java
findtheminecore.BoardSize.java
findtheminecore.Board.java
findtheminecore.Game.java
findtheminecore.Position.java
findtheminecore.RuleSet.java
findtheminecore.TileType.java
findtheminecore.Tile.java