public class Board { int size; Cell[][] cells; Board(int n) { size = n; cells = new Cell[size][size]; for (int row=0; row<size; row++) { for (int col=0; col<size; col++) { cells[row][col] = new Cell(); // create each Cell } } cells[5][4].setAlive(true); // put a glider in the middle cells[5][5].setAlive(true); cells[5][6].setAlive(true); cells[6][6].setAlive(true); cells[7][5].setAlive(true); }
public void paintComponent(Graphics)
inside a JFrame (with a BorderLayout to have the Panel
fill the whole drawable area, or setSize(int,int) for just part) to get double buffering
by defaultwhile (more input) {
next = nextToken()
if (next is operand)
push(next)
else apply next to top two operands and push the result
}
answer is on top of the stack