package be.qanar.slidingPuzzle;

public final class Position
{
	// points out positions in a table
	
	// constructor
	Position( int row, int column )
	{
		this.row    = row    ;
		this.column = column ;
	}
	
	@Override public String toString() 
	{
		return row + "/" + column ;
	}
	
	@Override public boolean equals( Object obj )
	{
		if( obj instanceof Position )
		{
			Position pos = ( Position )obj ;
			return pos.row == row && pos.column == column ;
		}
		return false ; 
	}
	
	// gives the position of the cell to the left of this position
	public Position toLeft()
	{
		return new Position( row, column - 1 ) ;
	}
	
	// gives the position of the cell to the right of this position
	public Position toRight()
	{
		return new Position( row, column + 1 ) ;
	}
	
	// gives the position of the cell above this position
	public Position toTop()
	{
		return new Position( row - 1, column ) ;
	}
	
	// gives the position of the cell below this position
	public Position toBottom()
	{
		return new Position( row + 1, column ) ;
	}
	
	public int row    ;
	public int column ;
}
