Skip to content
Anthony Christe edited this page Oct 30, 2013 · 4 revisions

Sudoku GUI

Assignment 8 - Sudoku Solver does not require the use of a GUI. However, I have provided one that allows you to interact with the sudoku board using a GUI. The GUI provides the following features:

Using the GUI

  • Add the SudokuGUI.java class to the same directory as Sudoku.java and SudokuTest.java
  • Important: Remove or rename the package to the correct package
  • Compile and run the SudokuGUI class

Opening and Saving Sudoku Boards

  • The Open button allows the user to choose a sudoku file to load
  • The Save button allows the user to save the current state of the sudoku board to a file
Sudoku File Format
  • The file format is a comma separated value (CSV) text file
  • Each row in the sudoku board is delimited by a new line in the text file
  • Each column in the sudoku board is delimited by a comma in the text file
  • The following is a representation of the file format where each N represents a digit 0 - 9 and 0 represents an empty space
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N
N,N,N,N,N,N,N,N,N

A valid partially filled sudoku file might look like:

7,8,0,0,9,0,0,2,0
1,0,0,0,0,0,9,6,4
0,0,0,2,5,1,0,0,0
0,0,6,1,8,5,0,0,0
5,0,4,0,0,0,3,0,2
0,0,0,3,4,2,5,0,0
0,0,0,9,6,3,0,0,0
6,4,1,0,0,0,0,0,3
0,9,0,0,1,0,0,5,7

I've already created the three example sudoku boards provided in SudokuTest. They are listed below.

Solving the Puzzle

The Solve button takes the current state of the board and:

  • Produces a 2d integer array representing the sudoku board in accordance with the assignment
  • Passes that array to Sudoku.fillSudoku
  • Checks the return status of fillSudoku
  • Displays "Solution found" if a valid solution was found and updates the board
  • Displays "Solution NOT found" if a solution is not found and does not update the board

Clone this wiki locally