From cc10c4fdde4576d56b5ae1957c7619fe8813fb36 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 13:47:23 +0100 Subject: [PATCH] Show proximity values on cells --- src/main/java/Minesweeper/Cell.java | 8 ++++++++ src/main/java/Minesweeper/MinesweeperGame.java | 2 +- src/main/java/Minesweeper/Playfield.java | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 36946f8..a455e88 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -13,4 +13,12 @@ public class Cell extends JButton { public Cell(CellType _type) { type = _type; } + + public void update() { + if(type == CellType.Number) { + setText(String.valueOf(value)); + } else { + + } + } } diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index fde06cd..231c674 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -18,7 +18,7 @@ public class MinesweeperGame extends JPanel { public static void main(String[] args) { JFrame f = new JFrame(); - MinesweeperGame ttt = new MinesweeperGame(3, 0); + MinesweeperGame ttt = new MinesweeperGame(8, 10); f.add(ttt); f.setSize(WIDTH, HEIGTH); diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index a56dbc6..9f52d84 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -99,6 +99,8 @@ public class Playfield { cells[row][column].value++; } } + + cells[row][column].update(); } }