Class Location

java.lang.Object
  extended by Location

public class Location
extends Object

Represent a location in a rectangular grid.

Version:
2011.07.31
Author:
David J. Barnes and Michael Kölling

Constructor Summary
Location(int row, int col)
          Represent a row and column.
 
Method Summary
 boolean equals(Object obj)
          Implement content equality.
 int getCol()
           
 int getRow()
           
 int hashCode()
          Use the top 16 bits for the row value and the bottom for the column.
 String toString()
          Return a string of the form row,column
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location(int row,
                int col)
Represent a row and column.

Parameters:
row - The row.
col - The column.
Method Detail

equals

public boolean equals(Object obj)
Implement content equality.

Overrides:
equals in class Object

getCol

public int getCol()
Returns:
The column.

getRow

public int getRow()
Returns:
The row.

hashCode

public int hashCode()
Use the top 16 bits for the row value and the bottom for the column. Except for very big grids, this should give a unique hash code for each (row, col) pair.

Overrides:
hashCode in class Object
Returns:
A hashcode for the location.

toString

public String toString()
Return a string of the form row,column

Overrides:
toString in class Object
Returns:
A string representation of the location.