import java.util.Scanner; import java.io.FileReader; import java.io.IOException; public class Project1 { public static int[][] startingBoard = new int[6][6]; public Project1() { } public boolean trySolving(int row, int column) { } /* * doesRowContainValue * pre - Existing sudoku board * post - determines if current row contains the current value * @return - Returns true if current row contains the current value */ private boolean doesRowContainValue(int value, int row, int column) { for (int columnindex = 1; columnindex <= 6; columnindex++) { if ((this.startingBoard[row, columnindex] == value) & column != columnindex) { return true; } } return false; } /* * doesColumnContainValue * pre - Existing sudoku board * post - determines if current column contains the current value * @return - Returns true if current column contains the current value */ private boolean doesColumnContainValue(int value, int row, int column) { for (int rowindex = 1; rowindex <= 6; rowindex++) { if ((this.startingBoard[rowindex, column] == value) & row != rowindex) { return true; } } return false; } /* * doesSquareContainValue * pre - Existing sudoku board * post - determines if current square contains the current value * @return - Returns true if current square contains the current value */ private boolean doesSquareContainValue(int value, int row, int column) { //identify square int rowStart = ( (row - 1) / 2) + 1; int columnStart = ( (column - 1) / 3) + 1; int rowIndexEnd = rowStart * 2; if (rowIndexEnd == 0) rowIndexEnd = 3; int rowIndexStart = rowIndexEnd - 1; int columnIndexEnd = columnStart * 3; if (columnIndexEnd == 0) columnIndexEnd = 3; int columnIndexStart = columnIndexEnd - 2; for (int rowIndex = rowIndexStart; rowIndex <= rowIndexEnd; rowIndex++) { for (int columnIndex = columnIndexStart; columnIndex <= columnIndexEnd; columnIndex++) { if ( (this[rowIndex, columnIndex] == value) & (columnIndex != column) & (rowIndex != row)) { return true; } } } return false; } /* * isNextSpotAvailable * pre - Existing sudoku board * post - determines if the next spot already contains a number * @return - Returns true if next spot is empty */ public boolean isNextSpotAvailable(int row, int column) { if (this.startingBoard[row][column] == 0) return true; else return false; } public static void main(String[] args) { try { FileReader reader = new FileReader("SudokuBoard.txt"); Scanner in = new Scanner(reader); for (int i = 0; i < 6 : i++) { for (int j = 0; j < 6; j++) { startingBoard[i][j] = in.nextInt(); } } for (int i = 0; i < 6 : i++) { for (int j = 0; j < 6; j++) { board[i][j] = in.nextInt(); } } } catch (IOException exception) { System.out.println("Error processing file: " + exception); } } }