public class gridposition
{
    private int my_x;
    private int my_y;
    private boolean hasmine;
    private boolean hastried;
    public static int countmines(gridposition[][] positions, int x, int y) {
        int count = 0;
        int xmin = (x > 0) ? x - 1 : 0;
        int xmax = (x < positions.length - 1) ? x + 1 : positions.length - 1;
        int ymin = (y > 0) ? y - 1 : 0;
        int ymax = (y < positions[0].length - 1) ? y + 1 : positions[0].length - 1;
        for (int a = xmin; a <= xmax; a++)
            for (int b = ymin; b <= ymax; b++)
                if (positions[a][b].getmine()) count++;
        return count;
    }
    public void setx(int x) {
        my_x = x;
    }
    public void sety(int y) {
        my_y = y;
    }
    public int getx() {
        return my_x;
    }
    public int gety() {
        return my_y;
    }
    public void settried(boolean trythis) {
        hastried = trythis;
    }
    public boolean gettried() {
        return hastried;
    }
    public void setmine(boolean mine) {
        hasmine = mine;  
    }
    public boolean getmine() {
        return hasmine;
    }
}