ITI 1121. Introduction to Computing II - Summer 2015

Assignment 3: Implementing a GUI to solve SUDOKU puzzle (100 points, weight 6.25%)

(Last Modified in July 7, 2015)

NOTE: unlike other assignments this assignment can be done in groups of 2 students or individually.

Due date: Monday July 20 at 11:59PM.
The assignment must be uploaded on Virtual Campus by the due date.
Late assignments are accepted between 1 min late up to a maximum of 24 hours late and they will receive a 30% penalty.

Learning objectives

For this assignment you will write a simple Graphical User Interface to allow a user to play the Sudoku puzzle.

Sudoku Puzzle

SUDOKU is a placement puzzle in which symbols from 1 to 9 are placed in cells of a 9 x 9 grid made up of nine 3 x 3 subgrids, called regions. The grid is partially filed with some symbols (the "givens"). The grid must be completed so that each row, column and region contains exactly one instance of each symbol. A valid SUDOKU puzzle must have a unique solution; thus for a totally filled SUDOKU grid, not every set of cells chosen to be the "givens" can yield a valid puzzle.

There are many interesting algorithmic questions regarding SUDOKU such as: solving Sudoku puzzles, creating valid puzzles, checking if a set of givens is valid and how many solutions it yields. We are NOT going to concentrate on these questions for this assignment. Instead, we are just going to build a GUI for someone to play SUDOKU. The SUDOKU grid with its givens and the solution of the puzzle are going to be known to the program before hand; the program will prevent the user to complete the grid with wrong numbers by checking the solution.


You are implementing a Graphical User Interface (GUI) to allow a user to play Sudoku. Here are some screenshots of our implementation of this GUI:

You are given interface as well as classes and
You must implement classes SudokuGame and SudokuBoard that will deal with important aspects of the GUI.
Indeed, you may refer back to Laboratory 5 for a comparison or to use as a basis for your code.
SudokuGame is the main GUI holding the frame (in Lab5 refer to that contains a Panel (with a restart Button and a status Label) and an object of a class called SudokuBoard which extends Canvas and is also an ActionListener (in Lab 5 refer to
SudokuBoard is used as a Canvas to draw the board and will also declare a private class that implements a MouseListener. This mouse listener must implement a method "public void mouseClicked(MouseEvent e)" which will retrieve the coordinates of the point where the click was done and identify which Sudoku cell it lies on. After a click a pop-up dialog box must be launched where the user can type the value to be filled in that cell. Note that if the cell is a "given" (number in blue above) or a previously filled value (number in black above), the click should have no effect. In SudokuBoard, the method "public void paint(Graphics g)" of Canvas must be overridden in order to paint the canvas with the current info on the Sudoku board. We suggest the use of java.awt.Graphics2D which extends java.awt.Graphics since it provides a better control over geometry than java.awt.Graphics, for rendering 2-dimensional shapes, texts and images. Class SudokuBoard will also have the main logic that controls the filling of cells with numbers, and prevent a cell to be filled with a incorrect number, by holding information about the status of the game, values filled in cells, and having access to the SudokuMatrix object for the puzzle used.

Details and requirements


Extra Useful Information

We may want to check the following information on specific classes and methods:

Rules and regulations (5/100)

Please follow the general directives for assignments.
You must abide by the following submission instructions:
For assignments of groups of two students only one student submits the code; the name of both students must be clearly indicated, also including in StudentInfo display. The other student must submit (by the due date) a text file named "PARTNER.txt" containing the name and student number of the partner who would have already submitted the code.
Include all your java files into a director called u1234567 where 1234567 is your student id.
Zip this directory and submit via blackboard.
The directory must contain the following files (with your implementation): The assignment is individual or in group of 2 (plagiarism or collaborations towards the solution of the assignment between groups will not be tolerated).
Read the information on academic fraud from other assignments.