import java.util.Random;
public class Minesweeper{
  /*
  0: empty space:
  1 ~ 8 : bomb next to it
  9: key bomb (same bomb for successfully uncovered bombs in fail and pass)
  10: flag
  11: clicked bomb
  12: incorrect flags
  13: incorrect bombs
  14: covered space
  */
  private int[][] key, userArray, loss;
  private int colLoss,rowLoss;
  private int bombs;
  private Random box;

  public Minesweeper(){
    box = new Random();
    easy();
  }
  public void easy(){
    key = new int[10][10];
    bombs = 10;
    for(int i = 0; i< 10; i++){
      key[box.nextInt(10)][box.nextInt(10)] = 9;
    }
    numberSet();
    genUserArray(10);
  }
  public int[][] genUserArray(int length){
    userArray = new int[10][10];
    for(int i = 0; i < userArray.length; i++){
      for(int a = 0; a < userArray[0].length; a++){
        userArray[i][a] = 14;
      }
    }
    return userArray;
  }

  public void flag(int col, int row){
    userArray[col][row] = 10;
  }
  public boolean userVerify(int col, int row){
    boolean test = false;
    if(key[col][row] == 0){
      chainReaction();
      test = true;
    }
    if(key[col][row]==9){
      colLoss = col;
      rowLoss = row;
    }
    return test;
  }

  private void chainReaction(){
    //code that runs if user clicks a 0
  }
  private void numberSet(){
    //needs fixing
    //needs better design
    for(int i = 0; i < key.length; i++){
      for(int a = 0; a < key[0].length; a++){
        int count = 0;
        if(key[i][a] == 0){
          System.out.println("We meet" + i + " " + a);
          try{
            if(key[i+1][a] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          try{
            if(key[i-1][a] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          try{
            if(key[i][a+1] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          try{
            if(key[i][a-1] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          try{
            if(key[i+1][a+1] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          try{
            if(key[i-1][a+1] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }

          try{
            if(key[i+1][a-1] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          try{
            if(key[i-1][i-1] == 9){
              count++;
            }
            System.out.println("aaa");
          }
          catch(java.lang.ArrayIndexOutOfBoundsException e){
            System.out.println("doggy");
          }
          key[i][a] = count;
        }
        count = 0;
      }
    }
  }

  public void toString(int[][] arr){
    for(int a[] : arr){
      for(int b : a){
        System.out.print(b + " ");
      }
      System.out.println();
    }
  }
}
