Be sure that a mine is created with a probability of 10%.
Whats wrong in my code?
package com.codegym.games.minesweeper;
import com.codegym.engine.cell.*;
public class MinesweeperGame extends Game{
private final static int SIDE = 9;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
private int countMinesOnField;
public void initialize (){
setScreenSize(SIDE, SIDE);
createGame();
}
private void createGame(){
int countMines = 0;
for(int y = 0; y < SIDE; y++ ){
for(int x = 0; x < SIDE; x++){
int rand = getRandomNumber(10);
setCellColor(x, y, Color.GREY);
if(rand == 9){
gameField[y][x] = new GameObject(x, y, false);
} else {
gameField[y][x] = new GameObject(x, y, true);
countMines += 1;
}
}
}
countMinesOnField = countMines;
}
}