public class EightQueens
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
private static java.util.ArrayList<java.util.ArrayList<Queen>> |
allSolutions |
An ArrayList of ArrayLists holding Queens
that holds all of the possible solutions for the eight queens problem
|
private static int |
PAUSE |
The number of milliseconds the program will pause in between each solution.
|
| Constructor | Description |
|---|---|
EightQueens() |
| Modifier and Type | Method | Description |
|---|---|---|
static boolean |
addQueen(int row,
int col,
java.util.ArrayList<Queen> currentBoard) |
This is an expanded version of the other addQueen method in this class.
|
static boolean |
addQueen(java.util.ArrayList<Queen> currentQueens) |
Recursively finds a solution to the eight queens thought problem.
|
static boolean |
isValid(int row,
int col,
java.util.ArrayList<Queen> currentQueens) |
Checks the validity of a spot on the board.
|
static void |
main(java.lang.String[] args) |
private static java.util.ArrayList<java.util.ArrayList<Queen>> allSolutions
private static final int PAUSE
public static boolean addQueen(java.util.ArrayList<Queen> currentQueens)
currentQueens - the Queens that have already been placedpublic static boolean addQueen(int row,
int col,
java.util.ArrayList<Queen> currentBoard)
row - the row to start looking atcol - the column to start looking atcurrentBoard - the queens currently placedpublic static boolean isValid(int row,
int col,
java.util.ArrayList<Queen> currentQueens)
row - the row of the spot to be checkedcol - the column of the spot to be checkedcurrentQueens - an ArrayList containing the already-placed Queenspublic static void main(java.lang.String[] args)
throws java.lang.InterruptedException
java.lang.InterruptedException