com.editev.chess
Class Square

java.lang.Object
  |
  +--com.editev.chess.Square

public class Square
extends java.lang.Object
implements java.util.Enumeration, java.lang.Cloneable

This class represents a Square on a chess board as a column and row position.

See Also:
the source here.

Field Summary
 byte column
          The column address of this square in the chess board with column=0 meaning file a and column=7 meaning file h in algebraic chess notation.
 byte row
          The row address of this square in the chess board with row=0 meaning rank 8 in algebraic chess notation.
 
Constructor Summary
Square()
          Create an empty square
Square(byte column, byte row)
          Create a square with a column and row value.
Square(int column, int row)
          Create a square with an int column and row value.
 
Method Summary
 java.lang.Object clone()
          Clone an Object that's a Square that's an exact copy of this one.
 Square cloneSquare()
          Clone a Square that's an exact copy of this one.
 void copyFrom(Square square)
          Copy another Square into this Square.
 boolean equals(java.lang.Object object)
           
 java.util.Enumeration getEnumeration()
          Enumerates all squares in row-major order, start right before the first element.
 java.util.Enumeration getEnumeration(byte row, byte column)
          Enumerates all squares in row-major order, start right before the first element.
 boolean hasMoreElements()
          Implements Enumeration in row-major order.
 boolean isValid()
          Is this Square inside the board? Squares are valid, Moves are legal....
 boolean isWhite()
          Is this a white square?
 java.lang.Object nextElement()
          Implements Enumeration in row-major order.
 java.lang.String toString()
          Square in chess notation.
 
Methods inherited from class java.lang.Object
, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

row

public byte row
The row address of this square in the chess board with row=0 meaning rank 8 in algebraic chess notation.

column

public byte column
The column address of this square in the chess board with column=0 meaning file a and column=7 meaning file h in algebraic chess notation.
Constructor Detail

Square

public Square()
Create an empty square

Square

public Square(byte column,
              byte row)
Create a square with a column and row value.

Square

public Square(int column,
              int row)
Create a square with an int column and row value.
Method Detail

isValid

public boolean isValid()
Is this Square inside the board? Squares are valid, Moves are legal....
Returns:
true if this square is within the confines of the chessboard.

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object
Returns:
true if Object is a Square and they have the same row and column elements.

getEnumeration

public java.util.Enumeration getEnumeration()
Enumerates all squares in row-major order, start right before the first element.

getEnumeration

public java.util.Enumeration getEnumeration(byte row,
                                            byte column)
Enumerates all squares in row-major order, start right before the first element.

hasMoreElements

public boolean hasMoreElements()
Implements Enumeration in row-major order.
Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Implements Enumeration in row-major order.
Specified by:
nextElement in interface java.util.Enumeration

toString

public java.lang.String toString()
Square in chess notation.
Overrides:
toString in class java.lang.Object
Returns:
Classic chess notation for this square

isWhite

public final boolean isWhite()
Is this a white square?
Returns:
true if this square is a white square.

clone

public java.lang.Object clone()
Clone an Object that's a Square that's an exact copy of this one.
Overrides:
clone in class java.lang.Object

cloneSquare

public Square cloneSquare()
Clone a Square that's an exact copy of this one.

copyFrom

public void copyFrom(Square square)
Copy another Square into this Square.