Class QueenNode

  • All Implemented Interfaces:
    java.io.Serializable

    public class QueenNode
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      QueenNode​(int dimension)
      Creates a QueenNode with a empty board
      QueenNode​(int x, int y, int dimension)
      Creates a QueenNode with one Queen on it
      QueenNode​(QueenNode n, int y)
      Creates a new QueenNode out of another QueenNode to add a new queen.
      QueenNode​(java.util.List<java.lang.Integer> pos, int y, int dimension)
      Creates a QueenNode with exiting positions of other queens
      QueenNode​(java.util.List<java.lang.Integer> pos, int x, int y, int dimension)
      Creates a QueenNode with exiting positions of other queens
    • Constructor Detail

      • QueenNode

        public QueenNode​(int dimension)
        Creates a QueenNode with a empty board
        Parameters:
        dimension - The dimension of the board.
      • QueenNode

        public QueenNode​(int x,
                         int y,
                         int dimension)
        Creates a QueenNode with one Queen on it
        Parameters:
        x - The row position of the queen.
        y - The column position of the queen.
        dimension - The dimension of the board.
      • QueenNode

        public QueenNode​(java.util.List<java.lang.Integer> pos,
                         int y,
                         int dimension)
        Creates a QueenNode with exiting positions of other queens
        Parameters:
        pos - The positions of the other queens.
        y - The column position of the newly placed queen.
        dimension - The dimension of the board.
      • QueenNode

        public QueenNode​(java.util.List<java.lang.Integer> pos,
                         int x,
                         int y,
                         int dimension)
        Creates a QueenNode with exiting positions of other queens
        Parameters:
        pos - The positions of the other queens.
        x - The row position of the newly placed queen.
        y - The column position of the newly placed queen.
        dimension - The dimension of the board.
      • QueenNode

        public QueenNode​(QueenNode n,
                         int y)
        Creates a new QueenNode out of another QueenNode to add a new queen.
        Parameters:
        n - The old QueenNode.
        y - The column position of the new queen.
    • Method Detail

      • getPositions

        public java.util.List<java.lang.Integer> getPositions()
      • getDimension

        public int getDimension()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • boardVisualizationAsString

        public java.lang.String boardVisualizationAsString()
      • attack

        public boolean attack​(int i,
                              int j)
        Checks if a cell is attacked by the queens on the board
        Parameters:
        i - The row of the cell to be checked.
        j - The collumn of the cell to be checked.
        Returns:
        true if the cell is attacked, false otherwise.
      • toStringAttack

        public java.lang.String toStringAttack()
      • getNumberOfQueens

        public int getNumberOfQueens()
      • getNumberOfAttackedCells

        public int getNumberOfAttackedCells()
        Returns the number of attacked cells of the current boardconfiguration
        Returns:
        The number of attacked cells.
      • getNumberOfAttackedCellsInNextRow

        public int getNumberOfAttackedCellsInNextRow()
                                              throws java.lang.InterruptedException
        Returns the number of attacked cells in the next free row from top down.
        Returns:
        The number of attacked cells in the next row.
        Throws:
        java.lang.InterruptedException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getNumberOfNotAttackedCells

        public int getNumberOfNotAttackedCells()