I guess there is not much introduction on this, since most should know what is Minesweeper.
- Create and implement a Game class, with public properties of Width, Height, MineCount, GameState (with 3 possible values of Playing, Win, and Lose), and ElapsedTime (which reflects to the actual elapsed time on different calls).
- Implement a GameCell class, with public properties of X (from 1 to Width) and Y (from 1 to Height).
- Implement boolean properties of Picked (whether the cell is picked by the player), Mine (whether the cell has a mine), Marked (whether the cell is marked by the player as suspected having mine), IsLoseCell (a cell with a mine that is picked by the player, making the game lost). Finally, implement a nullable integer property named Number, representing the number of mines around it after being picked.
- Go back to Game class, and implement method Get(int x, int y), which should return the GameCell instance whose X and Y matches with the parameters as long as x and y is within the boundary. All other properties should be at default value of its types (false for boolean, nullable for nullable integer).
- Implement method SetMine(int x, int y) or SetMine(GameCell cell). The method will change the cell's property Mine to true.
- Implement method SetRandomMines(). The method will pick a number of cells randomly (based on the MineCount), and set mines on them (consider reusing SetMine).
- Implement method Pick(int x, int y) or Pick(GameCell cell). If the cell picked is the Mine, set the IsLoseCell property as true, and change the GameState to Lose. Otherwise, the cell picked should have its Picked property changed to true, and Number property set to be the number of mines around it. If the Number turns out to be 0, automatically Pick all (unpicked) neighbor cells (with the same rule as the first pick).
- After a pick, check if the game contains any cell that is not mine and is not picked. If there is none, change the GameState to Win.
- When GameState changes to Win or Lose, the ElapsedTime should stop changing.