
/*
 * This class models the grid of the entire board and also
 * has a print method...
 */

public class Grid {

  private int width_, height_, numMines_;

  private Square [][] grid_;

  public Grid(int x, int y, int numMines){
    
    width_ = x;
    height_ = y;
    numMines_ = numMines;
    
    grid_ = new Square[width_][height_];

  }


  public void createGrid(){
    
    java.util.Random randomizer = new java.util.Random();
    
    int randomX, randomY;
    
    for (int i=0; i<numMines_; i++){

      randomX = (int) (randomizer.nextDouble() * 100);
      randomY = (int) (randomizer.nextDouble() * 100);

      grid_[randomX][randomY] = new MineSquare();

    }

    
    for (int y=0; y<height_; y++){
      for (int x=0; x<width_; x++){
	if (grid_[x][y] == null){
	  grid_[x][y] = new NumberSquare();
	}
      }
    }


  }

  public void printGrid(){
    System.out.println(""); // this gives clearer space
    for (int y=0; y<height_; y++){
      for (int x=0; x<width_; x++){
	System.out.println(" ");
	grid_[x][y].printSquare();
      }
    }
   System.out.println(""); // this ends it so it does not cram into the bottom
  }
    


}
