Class BoardPoint

java.lang.Object
  extended by BoardPoint

public class BoardPoint
extends java.lang.Object

A BoardPoint is a class that corresponds to a point on the game board.

Author:
willb

Constructor Summary
BoardPoint()
           
 
Method Summary
static BoardPoint fromCoordinates(int x, int y)
          Factory method that returns a reference to a newly-allocated BoardPoint that corresponds to given column and row numbers.
static BoardPoint fromString(java.lang.String s)
          Factory method that returns a reference to a newly-allocated BoardPoint that corresponds to a given column and row designation.
 int getX()
          Returns the column number of this BoardPoint, numbered from 0-9 inclusive.
 int getY()
          Returns the row number of this BoardPoint, numbered from 0-9 inclusive.
static boolean isValid(java.lang.String s)
          Returns true if the string given represents a valid board coordinate.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoardPoint

public BoardPoint()
Method Detail

fromString

public static BoardPoint fromString(java.lang.String s)
Factory method that returns a reference to a newly-allocated BoardPoint that corresponds to a given column and row designation. Precondition: s satisfies the requirement below.

Parameters:
s - a string consisting of a letter from A through J followed by a number from 1 to 10
Returns:
a newly-allocated BoardPoint

fromCoordinates

public static BoardPoint fromCoordinates(int x,
                                         int y)
Factory method that returns a reference to a newly-allocated BoardPoint that corresponds to given column and row numbers. Precondition: x and y are within 0-9 inclusive.

Parameters:
x - a row number
y - a row number
Returns:
a newly-allocated BoardPoint

isValid

public static boolean isValid(java.lang.String s)
Returns true if the string given represents a valid board coordinate.

Parameters:
s -
Returns:
true if s corresponds to a valid board coordinate.

getX

public int getX()
Returns the column number of this BoardPoint, numbered from 0-9 inclusive.

Returns:
the column number of this BoardPoint, numbered from 0-9 inclusive.

getY

public int getY()
Returns the row number of this BoardPoint, numbered from 0-9 inclusive.

Returns:
the row number of this BoardPoint, numbered from 0-9 inclusive.