Contest1
Class Cell

java.lang.Object
  |
  +--java.awt.Polygon
        |
        +--Contest1.Cell

class Cell
extends Polygon

Cell is a class that represents a triangular cell on the game board.

Since:
JDK1.2
See Also:
Serialized Form

Inner classes inherited from class java.awt.Polygon
Polygon.PolygonPathIterator
 
Field Summary
private  boolean isalive
          The state of this cell.
private  int[][] neighbors
          Triangles have 12 neighbors.
(package private)  boolean point_up
          Tells whether this triangle is situated on baord with its point up or down.
private  byte[] pointDownNeighborCol
          The offset column indicies for "point down" neighbors.
private  byte[] pointDownNeighborRow
          The offset row indicies for "point down" neighbors.
private  byte[] pointUpNeighborCol
          The offset column indicies for "point up" neighbors.
private  byte[] pointUpNeighborRow
          The offset row indicies for "point up" neighbors.
 
Fields inherited from class java.awt.Polygon
bounds, npoints, serialVersionUID, xpoints, ypoints
 
Constructor Summary
(package private) Cell(int row_index, int col_index, Point p, Dimension d, boolean point_up)
          Constructor for a triangularly shaped cell.
 
Method Summary
private  void assignNeighbors(int row, int col)
          Assigns the neighbors of this cell.
(package private)  void changeState()
          Switch the boolean state of cell's isalive value.
(package private)  void die()
          Sets the value of cell's isalive variable to false.
(package private)  int[][] getNeighbors()
          Gets the cell's neighbors.
(package private)  boolean isAlive()
          Returns value of isalive variable.
(package private)  void live()
          Sets value of cell's isalive variable to true,.
 
Methods inherited from class java.awt.Polygon
addPoint, calculateBounds, contains, contains, contains, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, translate, updateBounds
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

isalive

private boolean isalive
The state of this cell.

point_up

boolean point_up
Tells whether this triangle is situated on baord with its point up or down.

neighbors

private int[][] neighbors
Triangles have 12 neighbors.

pointUpNeighborRow

private byte[] pointUpNeighborRow
The offset row indicies for "point up" neighbors.

pointUpNeighborCol

private byte[] pointUpNeighborCol
The offset column indicies for "point up" neighbors.

pointDownNeighborRow

private byte[] pointDownNeighborRow
The offset row indicies for "point down" neighbors.

pointDownNeighborCol

private byte[] pointDownNeighborCol
The offset column indicies for "point down" neighbors.
Constructor Detail

Cell

Cell(int row_index,
     int col_index,
     Point p,
     Dimension d,
     boolean point_up)
Constructor for a triangularly shaped cell.
Parameters:
row_index - row index of the board
col_index - column index of the board
p - Point object specifying first vertext of triangle
d - Dimesnion object specifying width and height of cell
point_up - true if this triangle cell should point "up" false if should point down.
See Also:
Point, Dimension
Method Detail

isAlive

boolean isAlive()
Returns value of isalive variable.
Returns:
true if cell is alive, false otherwise

die

void die()
Sets the value of cell's isalive variable to false.

live

void live()
Sets value of cell's isalive variable to true,.

changeState

void changeState()
Switch the boolean state of cell's isalive value.

getNeighbors

int[][] getNeighbors()
Gets the cell's neighbors.
Returns:
two-dimensional integer array, row index in first dimension, column index in second dimension.

assignNeighbors

private void assignNeighbors(int row,
                             int col)
Assigns the neighbors of this cell.
Parameters:
row - row index of the cell for which to determine neighbors.
col - column index of the cell for which to determine neighbors.