1234567891011121314151617181920
  1. public class MineSweeper
  2. { private int[][] myTruth;
  3. private boolean[][] myShow;
  4. public void cellPicked(int row, int col)
  5. { if( inBounds(row, col) && !myShow[row][col] )
  6. { myShow[row][col] = true;
  7. if( myTruth[row][col] == 0)
  8. { for(int r = -1; r <= 1; r++)
  9. for(int c = -1; c <= 1; c++)
  10. cellPicked(row + r, col + c);
  11. }
  12. }
  13. }
  14. public boolean inBounds(int row, int col)
  15. { return 0 <= row && row < myTruth.length && 0 <= col && col < myTruth[0].length;
  16. }
  17. }