public class gridposition
{
// the following 2 variables show what x and y
position this particular grid location is at
private int my_x;
private int my_y;
// this states whether or not a mine is at this grid
position
private boolean hasmine;
// this states whether or not the user has clicked
on this mine or not (or if it has been "clicked" by the
// game automatically due to the game determining
that this was safe to click to)
private boolean hastried;
// this is a static method you need to define.
This method needs to return the number of grid positions
// surrounding your current position that contain
mines. (surrounding in all 8 directions) The gridpositions
// array is a 2 dimensional array containing
references to gridposition objects for every single grid position
// x and y are the x and y value for a given
position.
// Make certain you make sure you do not try to
access elements of the array that do not exist when checking
// adjacent positions (ie: values < 0 or > the
size of the array - 1)
// this is worth 4 points
public static int countmines(gridposition[][]
positions, int x, int y) {
// REPLACE THE FOLLOWING LINE
return 0;
}
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;
}
}