1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
void recurseCheck (int row, int col, Grid theGrid)
{
if (row>9 || row<0 || col>9 || col<0 || theGrid.getArrIsMine(row,col)==true || theGrid.getArrCovered(row,col)==false || theGrid.getArrFlagged(row,col)==true)
return;
theGrid.setArrCovered(false,row,col);
theGrid.displayGrid();
if (theGrid.getArrMines(row, col)==0)
{
if (theGrid.getArrIsMine(row-1,col-1)==false && theGrid.getArrFlagged(row-1,col-1)==false && theGrid.getArrCovered(row-1,col-1)==true && col>0 && row>0)
recurseCheck(row-1,col-1,theGrid);
if (theGrid.getArrIsMine(row-1,col)==false && theGrid.getArrFlagged(row-1,col)==false && theGrid.getArrCovered(row-1,col)==true && row>0)
recurseCheck(row-1,col,theGrid);
if (theGrid.getArrIsMine(row-1,col+1)==false && theGrid.getArrFlagged(row-1,col+1)==false && theGrid.getArrCovered(row-1,col+1)==true && row>0 && col<9)
recurseCheck(row-1,col+1,theGrid);
if (theGrid.getArrIsMine(row,col-1)==false && theGrid.getArrFlagged(row,col-1)==false && theGrid.getArrCovered(row,col-1)==true && col>0)
recurseCheck(row,col-1,theGrid);
if (theGrid.getArrIsMine(row,col+1)==false && theGrid.getArrFlagged(row,col+1)==false && theGrid.getArrCovered(row,col+1)==true && col<9)
recurseCheck(row,col+1,theGrid);
if (theGrid.getArrIsMine(row+1,col-1)==false && theGrid.getArrFlagged(row+1,col-1)==false && theGrid.getArrCovered(row+1,col-1)==true && row<9 && col>0)
recurseCheck(row+1,col-1,theGrid);
if (theGrid.getArrIsMine(row+1,col)==false && theGrid.getArrFlagged(row+1,col)==false && theGrid.getArrCovered(row+1,col)==true && row<9)
recurseCheck(row+1,col,theGrid);
if (theGrid.getArrIsMine(row+1,col+1)==false && theGrid.getArrFlagged(row+1,col+1)==false && theGrid.getArrCovered(row+1,col+1)==true && row<9 && col<9)
recurseCheck(row+1,col+1,theGrid);
}
theGrid.displayGrid();
}
|