import objectdraw.*; import java.awt.*; // draws a standard 8x8 checkerboard public class Checkerboard extends FrameWindowController { // location and dimensions of the board private static final int LEFT = 20, TOP = 20, SQUARE_SIZE = 20; // number of squares along the side of the board private static final int SIDE_SQUARES = 8; // draw the FilledRects that make up the board, row by row public void begin() { for (int row = 0; row < SIDE_SQUARES; row++) { for (int col = 0; col < SIDE_SQUARES; col++) { int squareX = LEFT + col * SQUARE_SIZE; int squareY = TOP + row * SQUARE_SIZE; FilledRect square = new FilledRect( squareX, squareY, SQUARE_SIZE, SQUARE_SIZE, canvas); if ((row + col) % 2 == 0) { square.setColor(Color.RED); } } } } }