Day 1
The first thing I did was create the game class so that it can ask
questions and keep the answers. Here are my attempts at it:
GameController.java:76: '}' expected. } ^ GameController.java:24: Return required at end of boolean askLevel(). public boolean askLevel(){ ^
When I went to line 24, I realized that I only had a return if the level did not equal zero. I added an else and it was cool. I compiled again with the updated Version 2 of Game Controller.
I also found out that there is a method in ReadInput.java that clears the rest of the line so I will use that! While I was fixing that, I added a few elements of clarity to my questions.
java.lang.ArrayIndexOutOfBoundsException: 95 at Grid.createGrid(Compiled Code) at GameController.createGame(Compiled Code) at GameController.startGame(Compiled Code) at mine.main(Compiled Code)
Started into Grid:createGrid Entering first for loop in Grid:createGrid first for loop, Grid:createGrid; number: 0 java.lang.ArrayIndexOutOfBoundsException: 23 at Grid.createGrid(Compiled Code) at GameController.createGame(Compiled Code) at GameController.startGame(Compiled Code) at mine.main(Compiled Code)
randomX = (int) (randomizer.nextDouble() * 100); randomY = (int) (randomizer.nextDouble() * 100);
java.lang.ArrayIndexOutOfBoundsException: -1 at Grid.getNeighbors(Compiled Code) at Grid.createGrid(Compiled Code) at GameController.createGame(Compiled Code) at GameController.startGame(Compiled Code) at mine.main(Compiled Code)
public int getNeighbors(int x, int y){
int returnValue = 0;
for (int iy=(y-1); iy<(y+1); iy++){
for (int ix=(x-1); ix<(x+1); ix++){
if (!(ix<0 || iy<0 || ix>width_ || iy>height_)){
// Do nothing
}
else if(grid_[ix][iy] == null){
// Do nothing
}
else if(grid_[ix][iy].amMine()){
returnValue++;
}
}
}
return returnValue;
}
public void uncoverNeighbors(int x, int y){
for (int iy=(y-1); iy<(y+1); iy++){
for (int ix=(x-1); ix<(x+1); ix++){
if (ix<0 || iy<0 || ix>width_ || iy>height_){
// Do nothing
}
else {
grid_[ix][iy].uncoverSquare();
}
}
}
}
uncovering 4, 4 x x x x x x x x x x x x x x x x x x 1 x x x x x x x x 0 x x x x x x x x 0 x x x x x x x x x x x x x x x x x x x x x x x x x x x
else if(ix==x || iy==y){
System.out.println("Can't uncover self");
// Do nothing
}
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x 0 0 0 0 0 1 1 x 0 0 0 0 0 0 B 2