Created
May 3, 2021 08:21
-
-
Save Tynael/6e71d1fe2dfc2190f606b09802622b9f to your computer and use it in GitHub Desktop.
Java Code Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MineSweeper { | |
private int[][] myTruth; | |
private boolean[][] myShow; | |
public void cellPicked(int row, int col) { | |
if (inBounds(row, col) && !myShow[row][col]) { | |
myShow[row][col] = true; | |
if (myTruth[row][col] == 0) { | |
for (int r = -1; r <= 1; r++) | |
for (int c = -1; c <= 1; c++) cellPicked(row + r, col + c); | |
} | |
} | |
} | |
public boolean inBounds(int row, int col) { | |
return 0 <= row && row < myTruth.length && 0 <= col && col < myTruth[0].length; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example used for: https://neutrondev.com/5-popular-programming-languages-and-their-uses/