Two Dimensional Array Iteration Help
Hi to all,
I'm trying to implement a maze creation class which needs a method to check the adjustment blocks (diagonal) to each block in my two dimensional array.
example:
Code:
//field
Block[][] maze = new Block[5][5];
//method
pubic boolean chechAdj(int x, int y){ //[I]x[/I] and [I]y[/I] are the current Block's indexes.
int count = 0;
for(Block[] Xblocks : this.maze){ //how can I slice [I]this.maze[/I] to -1 and +1 of [I]x[/I] and [I]y[/I] [B]excluding[/B] [I]x[/I] and [I]y[/I]?
for(Block block : Xblocks){
if(block.wall == true) count +=1;
}
}
return count;
}
This example checks the whole array. As you can see from my comments, I would like an elegant and javaish way for checking only the adjustment Blocks of the current one.
Any help would be greatly appreciated.
Thank you in advance,
George.