


to setMine(), or check isMine(), or the more straightforward isChecked() as opposed to isNotChecked(). Public ArrayList generateMinesLocation(int q)) Īs pointed out by it'll be better have methods that directly represents the exact actions we want on a Cell, i.e. Game.java: Main Class of the game, handles input and output and a number of other things (I am not sure whether I should remove this class or not). Here's the code on Github (not commented though). JPanel panel = new JPanel(new GridLayout(side,side)) įor(int i = 0 i loc = generateMinesLocation(10) 1 I made a Minesweeper game in Java 8, but I am not sure if the code is any good. I post basic working GUI version, if someone would like to run it.įtDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) However I will be gratefull for any commants and advices, also concenring OOP, code structure and style. These are two methods in Board Class: setCellValues() and scanForEmpt圜ells(). I wonder if my solution is reasonable (it works, but it look scary), and I would be great, if someone would review it. The hardest part for me, was a determining the value of single cells (how many mines is around it), and firing a chain reaction, if some cell was empty(value = 0) - it check closest cells, if they have value, it just reveal it, if they are empty it repeats process on them. Board - coordinating behavior of cells.Cell - controling behavior of single cell.I wrote a basic Minesweeper game for practice.
