
public class  queens  {


    private static void  solveQueens ( board chessBoard )  {

        if  ( chessBoard.success() )  {

            chessBoard.showBoard();
          }
        else  {

            for  ( int j = 1;  j <= chessBoard.getSize();  j++ )  {

                if  ( chessBoard.safeNextPosition(j) )  {

                    chessBoard.putNextQueen(j);

                    solveQueens( chessBoard );

                    chessBoard.removeLastQueen();
                  }
              }
          }
      }


    public static void  main ( String args[] )  {

        int size = 6;

        System.out.println( "" );
        System.out.print( "  Queens Problem of size: " );
        System.out.println( size );
        System.out.println( "" );

        solveQueens( new board(size) );

      }


  }
