From 4cbfc45a3de3a47c7f78663b11aa993c009e353c Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 15:02:28 +0100 Subject: [PATCH] Game End: Clicked on Mine --- src/main/java/Minesweeper/Cell.java | 2 ++ src/main/java/Minesweeper/Playfield.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 7b5e0de..93f8799 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -37,6 +37,8 @@ public class Cell extends JButton { protected void OnMouseClick() { if (type != CellType.Bomb) { flood(); + } else { + playfield.reset(); } } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index eed046b..38f61cc 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -2,6 +2,8 @@ package Minesweeper; import java.awt.Point; +import javax.swing.JOptionPane; + public class Playfield { private static final int CELLSIZE = 50; @@ -61,6 +63,7 @@ public class Playfield { } public void reset() { + JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!"); for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { MsG.remove(cells[i][j]);