Othello 1.0

edu.drexel.cs.ai.othello
Class Square

java.lang.Object
  extended by edu.drexel.cs.ai.othello.Square

public class Square
extends java.lang.Object

A class for representing an individual square in the othello board.

For a description of the string representation of Othello board squares, see here.

Author:
Evan A. Sultanik

Constructor Summary
Square(int row, int col)
          Constructs a new Square from a given row and column in the board.
Square(java.lang.String square)
          Constructs a new Square from a string representation of the row and column.
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns true if and only if the given object is instanceof Square and if o points to the same row and column as this.
 int getCol()
          Returns the column of this square.
 int getRow()
          Returns the row of this square.
 int hashCode()
          Returns a unique idendentifier for this square.
 java.lang.String toString()
          Returns a string representation of this square.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Square

public Square(java.lang.String square)
       throws java.lang.IllegalArgumentException
Constructs a new Square from a string representation of the row and column. Rows are numbered 0–7 from top to bottom and columns are labeled a–h from left to right.

    a    b    c    d    e    f    g    h
  -----------------------------------------
0 | a0 | b0 | c0 | d0 | e0 | f0 | g0 | h0 |
  -----------------------------------------
1 | a1 | b1 | c1 | d1 | e1 | f1 | g1 | h1 |
  -----------------------------------------
2 | a2 | b2 | c2 | d2 | e2 | f2 | g2 | h2 |
  -----------------------------------------
3 | a3 | b3 | c3 | d3 | e3 | f3 | g3 | h3 |
  -----------------------------------------
4 | a4 | b4 | c4 | d4 | e4 | f4 | g4 | h4 |
  -----------------------------------------
5 | a5 | b5 | c5 | d5 | e5 | f5 | g5 | h5 |
  -----------------------------------------
6 | a6 | b6 | c6 | d6 | e6 | f6 | g6 | h6 |
  -----------------------------------------
7 | a7 | b7 | c7 | d7 | e7 | f7 | g7 | h7 |
  -----------------------------------------

The row and column may occur in any order; "c6" is equivalent to "6c".

Throws:
java.lang.IllegalArgumentException - if a row and column could not be parsed from the string.

Square

public Square(int row,
              int col)
Constructs a new Square from a given row and column in the board. Note that no checking is done to ensure that the given arguments are within the bounds of the standard 8x8 othello board. Also note that the rows and columns are indexed from zero.

See Also:
Square(String)
Method Detail

getRow

public int getRow()
Returns the row of this square.


getCol

public int getCol()
Returns the column of this square.


toString

public java.lang.String toString()
Returns a string representation of this square.

Overrides:
toString in class java.lang.Object
See Also:
Square(String)

equals

public boolean equals(java.lang.Object o)
Returns true if and only if the given object is instanceof Square and if o points to the same row and column as this.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a unique idendentifier for this square. It is ensured that x.hashCode()==y.hashCode() implies x.equals(y).

Overrides:
hashCode in class java.lang.Object
See Also:
equals(Object)

Othello 1.0

Copyright 2006–2007 Evan A. Sultanik