Bonjour,
je ne vois pas mon erreur, je suis débutant et je voudrais votre aide.
Voici mon erreur :
After the createGame() method is executed, the countMinesOnField variable should be assigned the value of the number of mines in the field.
Merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.codegym.games.minesweeper;
 
import com.codegym.engine.cell.Color;
import com.codegym.engine.cell.Game;
 
public class MinesweeperGame extends Game {
    private static final int SIDE = 9;
    //The MinesweeperGame class must have a private GameObject[][] gameField 
    //matrix 
    //(two-dimensional array) whose dimensions are SIDExSIDE.
    private GameObject[][] gameField = new GameObject[SIDE][SIDE];
    private int countMinesOnField;
 
    @Override
    public void initialize() {
        setScreenSize(SIDE, SIDE);
        createGame();
    }
 
//The MinesweeperGame class must have a private void createGame() method.
    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, true);
 
                } else {
                    gameField[y][x] = new GameObject(x, y, false);
                    countMines += 1;
                }
            }
        }
        countMinesOnField = countMines;
    }
}