Package threeChess

Enum Position

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Position>

    public enum Position
    extends java.lang.Enum<Position>
    An enumeration of the 96 board positions. Each position has a colour, a row (0-3) and a column (0-7).
    • Method Detail

      • values

        public static Position[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Position c : Position.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Position valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getColour

        public Colour getColour()
        Returns:
        the position's colour
      • getRow

        public int getRow()
        Returns:
        the position's row
      • getColumn

        public int getColumn()
        Returns:
        the position's column
      • neighbour

        public Position neighbour​(Direction direction)
                           throws ImpossiblePositionException
        Gets the neighbouring cell in the given direction. Cells always move forward towards the center line, so the direction is independent of piece colour.
        Returns:
        the position in the specified direction.
        Throws:
        ImpossiblePositionException - if moving backwards from the back rank, or moving of the side of the board.
      • evenParity

        public boolean evenParity()
        returns true if the position has even parity equivalent to a black square on a traditional chess board.