Package at.jku.ssw.fp.sect04_3.puzzle
Class Pos
- java.lang.Object
-
- at.jku.ssw.fp.sect04_3.puzzle.Pos
-
public final class Pos extends Object
A position in a puzzle.- Author:
- Herbert Praehofer
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Pos(int row, int col)
Private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
hashCode()
boolean
isNeighbor(Pos other)
Tests if the given position is a neighbor of this positionboolean
isValid()
Tests if this position is within the range of the puzzle.static Pos
of(int row, int col)
Creats a position.String
toString()
-
-
-
Field Detail
-
N
public static final int N
Size of the puzzle- See Also:
- Constant Field Values
-
row
public final int row
the row index
-
col
public final int col
the column index
-
-
Method Detail
-
of
public static Pos of(int row, int col)
Creats a position.- Parameters:
row
- the row indexcol
- the column index- Returns:
- the position
-
isValid
public boolean isValid()
Tests if this position is within the range of the puzzle.- Returns:
true
if this position is within the range of the puzzle
-
isNeighbor
public boolean isNeighbor(Pos other)
Tests if the given position is a neighbor of this position- Parameters:
other
- the other position- Returns:
true
if the given position is a neighbor
-
-