diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 013a0bb..aa843a6 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -3,19 +3,19 @@ package Minesweeper; public class Playfield { private static final int CELLSIZE = 40; - private int playfieldSize; + private int Size; private MinesweeperGame MsG; - public Cell[][] playfield; + public Cell[][] cells; - public Playfield(MinesweeperGame _MsG, int _playfieldSize, int _bombAmount) { + public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; - playfieldSize = _playfieldSize; + Size = _Size; - playfield = new Cell[playfieldSize][playfieldSize]; + cells = new Cell[Size][Size]; int[] bPlacement = new int[_bombAmount]; for (int i = 0; i < bPlacement.length; i++) { - bPlacement[i] = (int) (Math.random() * playfieldSize * playfieldSize); + bPlacement[i] = (int) (Math.random() * Size * Size); for (int j = 0; j < i; j++) { if (bPlacement[i] == bPlacement[j]) { @@ -25,17 +25,17 @@ public class Playfield { } } - for (int i = 0; i < playfieldSize; i++) { - for (int j = 0; j < playfieldSize; j++) { - playfield[i][j] = new Cell(CellType.Number); + for (int i = 0; i < Size; i++) { + for (int j = 0; j < Size; j++) { + cells[i][j] = new Cell(CellType.Number); - playfield[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - playfieldSize * CELLSIZE / 2), - i * CELLSIZE + (MsG.HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, CELLSIZE); - MsG.add(playfield[i][j]); + cells[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - Size * CELLSIZE / 2), + i * CELLSIZE + (MsG.HEIGTH / 2 - Size * CELLSIZE / 2), CELLSIZE, CELLSIZE); + MsG.add(cells[i][j]); for (int k = 0; k < bPlacement.length; k++) { - if (bPlacement[k] == i * playfieldSize + j) { - playfield[i][j].type = CellType.Bomb; + if (bPlacement[k] == i * Size + j) { + cells[i][j].type = CellType.Bomb; break; } } diff --git a/src/test/java/Minesweeper/MinesweeperGameTest.java b/src/test/java/Minesweeper/MinesweeperGameTest.java index 2564d00..2dce81d 100644 --- a/src/test/java/Minesweeper/MinesweeperGameTest.java +++ b/src/test/java/Minesweeper/MinesweeperGameTest.java @@ -17,7 +17,7 @@ class MinesweeperGameTest { int bombCounter = 0; - for(Cell[] row : m.playfield.playfield){ + for(Cell[] row : m.playfield.cells){ for (Cell c : row) { if(c.type == CellType.Bomb) { bombCounter++;