Personal tools
You are here: Home Classes Fall 2004 - Spring 2005 CS 150 2.28.05 Grid.java
Document Actions

Grid.java

by admin last modified 2005-05-11 13:36

import java.awt.*;

class Grid { private Square[][] grid = new Square[100][100]; private int rows; private int cols;

public Grid(int r, int c) { rows = r; cols = c; int hsize = 500/c; int vsize = 500/r; int size; if (hsize < vsize) size = hsize; else size = vsize; for (int i = 0; i < rows; i++ ) for (int j = 0; j < cols; j++ ) { Square s = new Square(jsize, isize, size); grid[i][j] = s; s.makeVisible(); } }

public void color(int row, int col, String newColor ) { Square s = grid[row][col]; s.changeColor(newColor); }

public int firstRow() { return 0; }

public int lastRow() { return rows - 1; }

public int firstColumn() { return 0; }

public int lastColumn() { return cols-1; } }

 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: