Class Pos


  • public final class Pos
    extends Object
    A position in a puzzle.
    Author:
    Herbert Praehofer
    • Field Detail

      • row

        public final int row
        the row index
      • col

        public final int col
        the column index
    • Constructor Detail

      • Pos

        private Pos​(int row,
                    int col)
        Private constructor.
        Parameters:
        row - the row index
        col - the column index
    • Method Detail

      • of

        public static Pos of​(int row,
                             int col)
        Creats a position.
        Parameters:
        row - the row index
        col - 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object