Algorithm
Development Kit 1.0

algs.model.problems.tictactoe.model
Class Cell

java.lang.Object
  extended by algs.model.problems.tictactoe.model.Cell

public class Cell
extends java.lang.Object

Represents a column, row location on the TicTacToe board.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Field Summary
 int col
          The column for the board location.
 int row
          The row for the board location.
 
Constructor Summary
Cell(Cell c)
          Copy constructor.
Cell(int c, int r)
          Constructs a Cell object given a column and row.
 
Method Summary
 boolean equals(java.lang.Object o)
          Override equals() method from java.lang.Object.
 int hashCode()
          Hashcode must be implemented if this cell is to be used in a Hashtable.
 boolean isAdjacent(Cell c)
          Determines if this is adjacent to the given cell either horizontally or vertically.
 java.lang.String toString()
          Return representation of cell.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

col

public final int col
The column for the board location.


row

public final int row
The row for the board location.

Constructor Detail

Cell

public Cell(int c,
            int r)
Constructs a Cell object given a column and row.

Parameters:
c -
r -

Cell

public Cell(Cell c)
Copy constructor.

Parameters:
c -
Method Detail

equals

public boolean equals(java.lang.Object o)
Override equals() method from java.lang.Object.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Hashcode must be implemented if this cell is to be used in a Hashtable.

Overrides:
hashCode in class java.lang.Object

isAdjacent

public boolean isAdjacent(Cell c)
Determines if this is adjacent to the given cell either horizontally or vertically. Doesn't check for invalid c because we don't know the full size of the board within Cell.

Parameters:
c - desired cell against which to compare
Returns:
true if this is adjacent to c either horizontally/vertically; false otherwise.

toString

public java.lang.String toString()
Return representation of cell.

Overrides:
toString in class java.lang.Object

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.