Minesweeper (Part 4/16)

  • 3
  • Locked
We need to store the state of the playing field's cells somewhere. To do this, create a matrix (two-dimensional array) with the dimensions of the playing field. Populate the matrix with GameObject objects using this formula: gameField[y][x] = new GameObject(x, y); Now let's display all the cells o
You can't complete this task, because you're not signed in.
Comments (33)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Hoist
Level 21 , San Diego, United States
4 March, 04:53
Works. Look at both files carefully >> https://codegym.cc/help/4690 Suggest you read thru many postings in the HELP section to step thru each line. It's closer to real life programming with Minesweeper checking many many files interacting.
Olivier Boudigue
Level 18 , France, France
27 December 2022, 22:59
Hi, why gameField[y][x] = new GameObject(x, y); nd no gameField[x][y] = new GameObject(x, y); ??? Thank
bella
Level 0
7 December 2022, 04:11
非常不理解,之前试了很多次都不行。突然编译就可以了
Elektra
Level 15 , United States of America, United States
29 January 2022, 14:46
gameField[y][x] = new GameObject(x, y); I do not understand the logic of switching the x & y in the first part. I thought it was a typo. Can someone explain it to me please?
Roman
Level 41
9 February 2022, 07:36
You may have noticed that the matrix coordinates are different from the classical rectangular coordinate system (Cartesian coordinate system). When you access the matrix, you first specify the y coordinate and then the x coordinate. In mathematics, it is customary to specify the x coordinate first, i.e. (x, y). https://codegym.cc/groups/posts/140-games-section-on-codegym-useful-theory
Sneaky One
Level 5 , Germany, Germany
6 October 2021, 08:52
A couple of questions: 1. Does it make any difference wether I write the code this way gameField[x][y] = new GameObject(x, y); or this way gameField[y][x] = new GameObject(x, y); ??? It cracks me up that it's always x, y and then suddenly it is supposed to be y, x!? 2. I'm at the beginning of level 4 when it comes to the course. Today I took a look at the tasks and saw this Minesweeper task which is supposed to be level 0. At level 4 of the course we haven't even talked about arrays so far. So how does this all fit together? This Minsweeper task confronts me with arrays...how am I supposed to solve a level 0 task which obviously is not level 0! I am confused...
miguel
Level 12 , Corredor
10 April 2021, 20:47
I think this exercise is for a highest level... not for a begining level where I was learning to use System.out.println(); I don't understand... I hope to understand this code I later lessons... I had to download the solution...
Sulayman Mohamed
Level 3 , Manacor
29 March 2021, 02:11
i have this problem and I dont know why? com/codegym/games/minesweeper/part04/MinesweeperGame.java:18: error: cannot find symbol gameField[x][y] = new GameObject(x,y); ^ symbol: variable x location: class com.codegym.games.minesweeper.part04.MinesweeperGame
Roman
Level 41
29 March 2021, 05:48
Please post your question with the attached solution in the section Help.
Akriti Bagale
Level 0
17 May 2021, 11:45
it may be because you have not use the variable x and y in the for loop
祖安文科状元 Java Developer
26 March 2021, 03:10
import com.codegym.engine.cell.*; why i use idea ,no engine package?
祖安文科状元 Java Developer
26 March 2021, 03:20
just delete the CodeGymTask file,and reload the file.
JOJO
Level 3 , XI'AN, China
3 March 2021, 13:28
It's may useful; private GameObject[][] gameField = new GameObject[SIDE][SIDE]; "gameField[y][x] = new GameObject(x, y); " are at createGame() method
Nickolas Johnson
Level 8 , St. Louis, United States of America
4 December 2020, 22:17
If you're having trouble like I did take a step back and make sure everything you're doing is logically consistent. I tried to make this way harder than it was and missed a few small details. For me, it helps to read the requirements FIRST because it goes in a logical order. The description tends to start with the most complicated thing and glaze over the simple first steps.