SUDOKU PROJECT

Alejandro Ledesma Villacis 1º Telecommunications Engineering Group: 95

Structure:

oThe class Canvas2 (at the beginning first GUI), is where the board is created, the bitmasks defined( logic color code depending in the actions of the user), gives support for the print button and manage the mouse and keyboard events(it also limits the inputs from 0 to 9). §Maybe the most original aspects are the highlighting when the user put the mouse on a cell and the option of using the mouse to play (each click increments a digit once, if pressing Shift at the same time, it increments three times, and if pressing Control it clears the cell) , additionally the board´s cells are considering as paint components ( using the method paintComponent( Graphics g ) and the propertities of JCanvas to draw the rectangles and board defined in the “Introduction to graphics programming in Java”).

Structure:

The class SudokuSolver is the one which solves the Sudoku by means of recursion and backtracking( is a recursive brute-force solver )and also provides support for the Animated solving button and the creation of random Sudoku games( it takes one of the 10 Sudoku games I copied and select one by Math.random()) . In order to avoid problems, and in the case we want to add more Sudoku games in the source code, the parse( String s ) method is used in order to evaluate the elements of the string as numbers from 0 to 9 and the point `.` as the separator between rows.

§

§

Following the Canvas2 structure, a bitmask is defined for rows, columns and subpanels.

Structure:

The class HelpBox provides the window where the text instructions and information about the game will be seen from a file written in ASCII code text. The only remarkable features are the vertical scroll bar and the necessity of importing util.StringTokenizer in order to get the substrings separated and get the information from the files as we want. The class Repaintable is an interface used for provide support for the animated solving, as the board needs to be “updated” every time we “paint” something on.

§

Structure:

The class SudokuGUI is the main class of the sudokuProject, as it builds the whole graphical interface and runs the game itself. It gets the Board from Canvas2, creates the left-panel of buttons, the upperLine of messages and adds some decorative images. As well it calls the solver, changes the order of the Sudoku in order to creates new Random games, defines the methods for editing the fixed numbers and manages all the events of the buttons-panel. The SudokuGUI also get the information from the text files for the HelpBox,UpperLine and Buttons by using ResourceBundle.getBundle() . The class Animator is an inner class of SudokuGUI, it “repaints” the board while the solver is working by calling repaintRequested() from the Repaintable interface.

§ §

How to play:

•Starting window, we can input numbers with the mouse or keyboard on the cell we want, as it becomes highlighted when we pass by

•To start, we click in New Random Game to start to play . and an easy random Sudoku game is generated.

How to play:
•As we introduce the numbers they appear in blue…

•Whenever we want we can use the Clear button to erase the numbers we have inputted or the Clean the board button to erase all, even the fixed values.

How to play:
• • Whenever we want we can check our game, by pressing the button check. The wrong numbers will appear in read, while right numbers remain blue

•The Print button, will print the current board, popping-up the printer-window.

How to play:
•As we finish the Sudoku, we can check if all the numbers are right, or if we want to know directly the solution, we press the button Solve.

•Another option is the animated solving, which shows the program´s intermediate steps.

How to play:
•Another useful option is use the Edit and set initial position which allow us to modify the fixed values from the beginning, in this way, we can copy a Sudoku from a newspaper, magazine,etc. However the user have to make sure it has a solution, in spite of that the program will tell you if there´s any error when you press the Set •When we press the button help and instructions, a complete information about the game and how to play is displayed. •As well the exit button, will close the whole program.

The End

First SudokuGUI, I will never forget you…