Minesweeper Assignment Notes

function to find/"uncover" things in the minefield:

for ( r = ...) {      // for each cell
    for ( c = ...) {
        if ( cell[r][c] != ' ') continue; // ignore it if blank
        for (i = r - 1; i <= r+1; i++)  // check all of the neighboors...
            for (j = c-1; j<= c+1; j++) { // ...of that cell 
            // check to see if (i,j) is in bounds (see connect4)
                continue;
            }
        }
}
void mouseClicked(MouseEvent e) 
{
    Object source = e.getSource();
    int sx, sy;
    for (int r = 0; r < B.length; r++) {
        for (int c = 0; c < B[0].length; c++) {
            if (source == B[r][c]) {
                sy = r;
                sx = c;
            }
        }
    }

or:

Object source = e.getSource();
if (source instanceof MyButton) {
    sx = source.x;
    sy = source.y;
}
public void mouseClicked(MouseEvent e)
{
    // sx,sy   determine these
    if already uncovered, just return
    uncover the button
    if it's a mine, set to "game over" condition
    if it's a 0, the uncover all neighbors, etc.
    if everyting else in the field is a mine, win condition
}

Be sure to google "java swing" for GUI help / tutorials.

DUE TOMORROW SHIIIIT