I'm a newbie so please don't scald me too much as I'd just like to follow the good OOP trail from the very beginning :) So I'm coding a minesweeper in Java with Swing and for now, my code looks like this:
- a class with main() only which starts the game by creating an object Minesweeper()
- the Minesweeper class in which I create a JFRame, JPanel for menu (and ActionListener for it) and create a Grid(x,y) object
- the Grid(int width, int height) class which extends JPanel using which I create a grid with the given dimensions, put mines on it and handle all the playing
I have some worries about the Grid(), though. Is it OK to handle everything from drawing the desired number of JButtons, through setting mines on them and listening for clicks (and also addressing those clicks) to the finding_empty_cells algorithm in case user clicks on something other than bomb and we have to show the surrounding empties in one class? Doens't that violate the single responsibility principle? Or is it OK?