I am working on a Minesweeper which I have pretty much complete.
The only thing missing is the detection of winning. What would be the best way to implement this? I know its going to be part of the actionlistener that detects clicks, at some point the last click should detect a winner.
Could anyone give me some ideas thanks!
The player has won if
numUnopenedCells == numBombs
(where a cell is unopened if it is in its initial state, or flagged as a mine).
numUnopenedCells > numBombsthen the player has unopened cells which are not bombs (i.e. some work left to do)
numUnopenedCells < numBombsthen the player has necessarily "opened" a bomb cell and already lost.
I know its going to be part of the actionlistener that detects clicks, at some point the last click should detect a winner.
Yes, this snippet would be executed directly or indirectly by the action listener. I'd suggest you have a model of the game state, and in the
openCell(int x, int y) method you check the above, and take the appropriate action.