I need to add checkers to my checkerboard.
A checker is added only in rows 1,2,3,6,7 and 8. If using a loop, this corresponds to i = 0,1,2,5,6 and 7.
I need help writing a switch statement to place checkers on my checkerboard.
Here is the code for my checkerboard.
public class Checkers extends GraphicsProgram {
public void run() {
double sqSize = (double) getHeight() / N_ROWS;
for (int i = 0; i < N_ROWS; i++) {
for (int j = 0; j < N_COLUMNS; j++) {
double x = j * sqSize;
double y = i * sqSize;
GRect sq = new GRect(x, y, sqSize, sqSize);
sq.setFilled((i + j) % 2 != 0);
sq.setColor(Color.GRAY);
add(sq);
}
}
}
}
private static final int N_ROWS = 8;
private static final int N_COLUMNS = 8;
}