Computer Science Lab: Minesweeper

In this lab/assignment, students are required to create the game of minesweeper that is written in Java with the swing library. The lab provides an incomplete version of the game. The students need to complete the following 4 methods in MyGrid.java so that the game can function properly.

  • void initializeHints() : this method generates the numbers that tell the player how many mines are around a square
  • boolean checkDead(int r, int c): This method returns true if the player clicks a mine
  • boolean checkWin(): This method returns true when all the squares have been clicked except the squares containing bombs
  • void updateGrid(int r, int c): This method shows the number beneath the square. If the square is zero, the method will open all the adjacent squares that are not mines. The method will clear an area of zeros to enable faster play.

This lab was designed for an AP Computer Science course and was given to students after 2D arrays and recursion were taught.

For more information about the lab, you can visit https://jeffreywong.ca/programs/ap-computer-science-minesweeper-lab/

Free

Save for later
  • APCSMineSweeper-master.zip

About this resource

Info

Created: Oct 20, 2019

zip, 91 KB

APCSMineSweeper-master

Report a problem

Creative Commons "Sharealike"

Creative Commons "Sharealike"