I am starting to make a 8 x 8 square board for Chess Game Assignment. However, I am wondering if there's anything hint to create the square rather than the 2D array in Java.
one of the restrictions for the assignment disallows to use 2D array or any similar. There's no AI but user control only.
You can use one-dimensional array, say Figure [] board = new Figure[64]
and make a simple getter/setter method to emulate 2-dimensions:
Figure get(int hor, int vert) {
return board[hor*8+ver];
}
void set(int hor, int vert, Figure f) {
board[hor*8+ver] = f;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With