Class Queen

java.lang.Object
  |
  +--Queen
Direct Known Subclasses:
NeighborQueen

class Queen
extends java.lang.Object

Package-wide visible class. Located in file QueensOO.java. Represents one queen for an n-Queens problem solver. Used by public class QueensOO.


Field Summary
protected  int column
          column position of a Queen: is unchangable
protected  int row
          row position of a Queen: can be changed to obtain a conflict free solution
 
Constructor Summary
Queen(int c)
          Initializes a new Queen object.
 
Method Summary
protected  boolean advance()
          Advance one row if possible
 boolean findSolution()
          A single Queen is always at a conflict free position.
protected  boolean predecCanAttack(Queen queen)
          Test whether this Queen (with position row, column) can attack another queen
 void printSolution()
          Prints the position of the current Queen
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

row

protected int row
row position of a Queen: can be changed to obtain a conflict free solution

column

protected final int column
column position of a Queen: is unchangable
Constructor Detail

Queen

public Queen(int c)
Initializes a new Queen object.
Parameters:
c: - the column position
n: - the left neighbor Queen
Method Detail

findSolution

public boolean findSolution()
A single Queen is always at a conflict free position.
Returns:
true

advance

protected boolean advance()
Advance one row if possible
Returns:
true if the Queen can be advanced, false otherwise

predecCanAttack

protected boolean predecCanAttack(Queen queen)
Test whether this Queen (with position row, column) can attack another queen
Parameters:
queen - Queen to test
Returns:
true if attack is possible, false otherwise

printSolution

public void printSolution()
Prints the position of the current Queen