core
Class Position

java.lang.Object
  extended by core.Position

public class Position
extends Object

Position on the board.

Specification Fields

Field Summary
static Collection<Position> ALL
           
static Position[][] pos
           
 
Method Summary
static Position[][] ALLarray()
           
static Collection<Position> ALLfn()
           
 boolean equals(Object o)
           
static Position fromString(String s)
           
static Position get(int x, int y)
           
 int getX()
           
 int getY()
           
 int hashCode()
           
 boolean isValid()
           
static boolean isValid(int x, int y)
           
 String toString()
           
static boolean validPosition(String s)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

pos

public static final Position[][] pos

ALL

public static final Collection<Position> ALL
Method Detail

ALLarray

public static Position[][] ALLarray()

ALLfn

public static Collection<Position> ALLfn()

isValid

public static boolean isValid(int x,
                              int y)

isValid

public boolean isValid()

get

public static Position get(int x,
                           int y)

getX

public int getX()
Returns:
x of this position

getY

public int getY()
Returns:
y of this position

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object

fromString

public static Position fromString(String s)
Parameters:
s - is a String representing a chess position
Requires:
s is of the form [row][column], where the row is a character from a to h and the column is a number from 1 to 8. For example, c7 is a legal argument to this method, as is h4.
Returns:
a Position corresponding to the String s. Its toString method will return a String equal to s.

validPosition

public static boolean validPosition(String s)
Returns:
true if s is of the form [row][column], where the row is a character from a to h and the column is a number from 1 to 8. For example, c7 is a valid position String, as is h4.

toString

public String toString()
Overrides:
toString in class Object
Returns:
a String representation of this, of the form [column][row]. The columns are represented by letters from a to h, where a corresponds to a column argument of 1 to the constructor. The rows are numbered from 1 to 8. Thus, from White's perspective, the lower-left corner is a1, the lower-right corner is h1, and the upper-right corner is h8.