TicTacToeBoard - int y = (getHeight() - BOARD_SIZE) / 2; /*...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * File: TicTacToeBoard.java * ------------------------- * This program draws a Tic-Tac-Toe board at the center of the window. * This version uses constant for better programming style * * Author: CS1MD3, Sept. 2008 */ import acm.graphics.*; import acm.program.*; public class TicTacToeBoard extends GraphicsProgram { public void run() { /* gap between lines */ int gap = BOARD_SIZE / 3; /* coordinates of the upper-left corner of the board */ int x = (getWidth() - BOARD_SIZE) / 2;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int y = (getHeight() - BOARD_SIZE) / 2; /* draw horizontal lines */ add(new GLine(x, y + gap, x + BOARD_SIZE , y + gap)); add(new GLine(x, y + 2*gap, x + BOARD_SIZE, y + 2*gap)); /* draw vertical lines */ add(new GLine(x + gap, y, x + gap, y + BOARD_SIZE)); add(new GLine(x + 2*gap, y, x + 2*gap, y + BOARD_SIZE)); } /* constant BOARD_SIZE */ private static final int BOARD_SIZE = 180; }...
View Full Document

Ask a homework question - tutors are online