The answers point to the use of a static array, and that makes me feel sad in terms of OO.
How about getting your game pad to have a properly encapsulated structure with the addPiece method?
PlayingBoard myBoard = new PlayingBoard(); int i, j; for(i = 0; i < 12; i++) { for(j = 0; j < 12; j++) { myBoard.addPiece(i,j, 'x'); } }
Even then, if your parts themselves are smart, you need to create an object that wraps them, and not just store the char.
public PlayingPiece[][] _board = new PlayingPiece[8][8];
Also, you use 12 in the loop, but 8 in the initialization, so expect IndexOutOfBounds exceptions.
Jeff watkins
source share