Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess
Class Square

java.lang.Object
  extended byictk.boardgame.chess.Square
All Implemented Interfaces:
java.lang.Cloneable, Location

public class Square
extends java.lang.Object
implements Location, java.lang.Cloneable

this is a typical location on a chess board. It contains an occupant, file, and a rank.


Field Summary
 ChessPiece piece
          the piece standing on the square
 
Constructor Summary
Square()
           
Square(byte f, byte r)
           
Square(char f, char r)
           
 
Method Summary
 java.lang.String dump()
           
 boolean equals(java.lang.Object obj)
          checks to see of the file and rank are the same.
 int[] getCoordinatesNumeric()
          this returns an int array of the numberic representation of the file and the rank.
 byte getFile()
           
 char getFileAsChar()
          translates the file into its traditional english letter value ('a'-'h')
 ChessPiece getOccupant()
          same as getPiece() but returns the piece in the ChessPiece class
 Piece getPiece()
          gets the current occupant of the square.
 byte getRank()
           
 char getRankAsChar()
          translates the rank into its traditional Arabic number value ('1'-'8')
 int getX()
          this is the internal horizontal coordinate for the position.
 int getY()
          this is the internal vertical coordinate for the position.
 int hashCode()
           
 boolean isBlack()
          what color is this square on a traditional chess board?
 boolean isOccupied()
          is there a piece standing on this square.
 void set(byte f, byte r)
           
 void set(char f, char r)
           
 boolean setOccupant(ChessPiece p)
          this is the same as setPiece, but specific for the Chess package.
 Piece setPiece(Piece p)
          sets the occupant of the square
 void setX(int x)
           
 void setY(int y)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

piece

public ChessPiece piece
the piece standing on the square

Constructor Detail

Square

public Square()

Square

public Square(byte f,
              byte r)

Square

public Square(char f,
              char r)
Method Detail

getX

public int getX()
Description copied from interface: Location
this is the internal horizontal coordinate for the position.

Specified by:
getX in interface Location

getY

public int getY()
Description copied from interface: Location
this is the internal vertical coordinate for the position.

Specified by:
getY in interface Location

setX

public void setX(int x)
Specified by:
setX in interface Location

setY

public void setY(int y)
Specified by:
setY in interface Location

getPiece

public Piece getPiece()
gets the current occupant of the square.

Specified by:
getPiece in interface Location
Returns:
null if there is no occupant

setPiece

public Piece setPiece(Piece p)
sets the occupant of the square

Specified by:
setPiece in interface Location
Returns:
the piece that occupied this square before the method call

isBlack

public boolean isBlack()
what color is this square on a traditional chess board?


getFile

public byte getFile()
Returns:
1-8

getRank

public byte getRank()
Returns:
1-8

getFileAsChar

public char getFileAsChar()
translates the file into its traditional english letter value ('a'-'h')


getRankAsChar

public char getRankAsChar()
translates the rank into its traditional Arabic number value ('1'-'8')


isOccupied

public boolean isOccupied()
is there a piece standing on this square.


setOccupant

public boolean setOccupant(ChessPiece p)
this is the same as setPiece, but specific for the Chess package.


getOccupant

public ChessPiece getOccupant()
same as getPiece() but returns the piece in the ChessPiece class


set

public void set(byte f,
                byte r)

set

public void set(char f,
                char r)

getCoordinatesNumeric

public int[] getCoordinatesNumeric()
this returns an int array of the numberic representation of the file and the rank.


equals

public boolean equals(java.lang.Object obj)
checks to see of the file and rank are the same. The occupant doesn't matter.


hashCode

public int hashCode()

toString

public java.lang.String toString()

dump

public java.lang.String dump()

Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .