import objectdraw.*; import java.awt.*; /** * Tests if a square is a magic square. */ public class NumberGridEvents extends FrameWindowController { // size of the number grid private static final int GRID_SIZE = 3; // position of the text display private static final Location TEXT_POS = new Location(10, 10); // the number grid itself private NumberGrid square; // draw the number grid and check if it is a magic square public void onMousePress (Location point) { canvas.clear(); square = new NumberGrid(GRID_SIZE, canvas); square.print(point); if (square.isMagicSquare()) { new Text("Yes, it's a magic square!", TEXT_POS, canvas); } else { new Text("No, it's NOT a magic square!", TEXT_POS, canvas); } } }