This is my first post on here so be gentle lol. Anyway, I'm currently working on a Sudoku Solver for my CS 2420 class and I am having some major blocks with it. My goal is to represent a Sudoku puzzle using a Sudoku class, have the user input a file and build the Sudoku object putting the data in to a 2D array, print it to the console, and solve it using a standard backtracking algorithm. Here is the current code I have for the SudokuApp:

public class SudokuApp { public static void main (String[] args) throws IOException { Scanner glaDOS = new Scanner (System.in); System.out.print("PLEASE ENTER A VALID FILE NAME THAT CONTAINS A SUDOKU: "); File sudokuFile = new File (glaDOS.next()); Scanner glaDOS2 = new Scanner (sudokuFile); Sudoku puzzle = new Sudoku (glaDOS2); System.out.println ("Unsolved: "); System.out.println (puzzle); System.out.println ("Solved: " ); System.out.println (puzzle); System.out.println("Backtracking steps: "); } }

and my current code for the Sudoku class itself

public class Sudoku { //instance variables private int row; private int col; private String numbers; private char [][] puzzle; /** * * @param sudokuReader the scanner containing the puzzle * file to be read and scanned into an array * @throws IOException * */ public Sudoku (Scanner sudokuReader) { puzzle = new char [9][9]; for (int i = 0; i < 8; i++) { if(sudokuReader.hasNext()) { numbers = sudokuReader.next(); for (int j = 0; j < 8; j++) { puzzle[row][col] = numbers.charAt(j); } } } System.out.println(puzzle[9][9]); } /** * Method that checks to see if a number can be put in to * a specific position on the Sudoku board * @param row row position * @param col column position * @param num number being analyzed * @return value stating if the move is legal */ public boolean isLegal (int row, int col, int num) { return true; } /** * Methods that uses a backtracking algorithm to put * numbers into positions on the puzzle and tries to * solve it. If there is a solution, it returns true. * If there is no solution, it returns false. * @param row row position to start solving from * @param col column position to start solving from * @return value stating if puzzle can be solved */ public boolean solve (int row, int col, Sudoku puzzle) { // if(row++ == 8) //return true; //if (numbers.charAt(row, col) == '.') //return(solve(row++, col++, puzzle)); //for(int = 1; i < 10; i++) //{ //if(IsLegal(row, col, num)) //if(solve(row, col++, puzzle)) // return true; //else return false; } /** * Returns a string representing the contents of the * sudoku. * @return */ public String ToString() { return "Unsolved: " + puzzle; } }

I am getting all sorts of weird errors right now. One of them I know is something to do with Eclipse which I am working on. The other one I get is:

StringOutOfBoundsException:

String index out of range: 1 (in java.lang.string)

whenever I run the code in BlueJ. I know it has something to do with how the data is being read in to the array but I'm not exactly sure what is...Also for the solve and IsLegal methods, I'm not sure whether I should have the Sudoku puzzle itself be a parameter or have the 2-D array being used be the parameter or what.... If anyone could please give me a little bit of direction and help with the troubles I'm having, I would greatly appreciate it. Thank you to all