![]() If you are using JDK/TextEditor, create a sub-directory called sudoku and place the classes under the sub-directory.You can then create the classes under the sudoku package. In Eclipse/NetNeans/VSCode, first create a "Java Project" called "sudoku" then create a new package (new ⇒ package) also called sudoku.The method newPuzzle() can be used to generate a new puzzle for a new game.Īll the classes are kept in a package called sudoku. Puzzle: A class called Puzzle is designed to model the number puzzle, which holds the numbers and clues in 9x9 int array numbers and boolean array isGiven.SudokuMain: We further customize the JFrame, by creating a subclass called SudokuMain, to hold the GameBoardPanel ( JPanel) in its ContentPane.Similar to Cell, the GameBoardPanel has its own methods to paint() itself. GameBoardPanel: We also customize the JPanel, by creating a subclass called GameBoardPanel, to hold the grid of 9x9 Cells ( JTextFields).CellStatus: An enumeration ( enum) called CellStatus is designed to hold the status constants, including GIVEN, CORRECT_GUESS, WRONG_GUESS and TO_GUESS.The Cell has its own methods to paint() itself. Cell: We customize the JTextField, by creating a subclass called Cell, with additional variables row, col, number and status, to model each cell of the grid.SudokuConstants: To store the named constants such as GRID_SIZE - to be referred to as SudokuConstants.GRID_SIZE.However, it is hard to identify the row and column of the JTextField triggering an event.įor better OO and modular design, we design SIX classes (in a package called sudoku) as shown in the above class diagram: We could simply use 9x9 JTextFields (for entering guesses) arranged in 9x9 GridLayout on a JPanel/ JFrame's ContentPane. There is no known fast polynomial algorithm for solving the puzzle. Mathematically, Sudoku is a NP-complete problem. The One Rule can be compactly stated as: "Each digit appears once in each group." Rows, columns and boxes can be collectively referred to as groups, of which the grid has 27. The initially defined values are clues or givens. A grid has 9 rows, 9 columns and 9 boxes (or blocks or regions), each having 9 cells (or squares), for a total of 81 cells. the puzzle) is a partially completed grid. You could wiki "Sudoku" to understand the rules of the game. Do TODO 1 and run the program (2/10 points).The pre-requsite for this assignment is: You shall be able to program "SwingPhoneApp" in the "Exercises: Graphics Programming". Put all four 1,2,3,4,5 digits in 5 vertical columns, 5 horizontal rows, 5 different colored areas.Unfortunately, you have only little time to complete this mini-assignment. You can also highlight particular numbers to make it easier to think. If you are confused, use the memo mode! Multiple numbers can be written on the same square. ![]() The puzzle is auto-saved, so you can continue playing from the place you quitted. Since Sudoku puzzles are generated automatically, you can play with infinite number of Sudoku puzzles at each level! Level 1 is very very easy, but it gets harder as the level goes up. There are 100 levels in the puzzle, so start with the one you can do easily. ![]() It's beginners of Sudoku, but a little eccentric modified version.Īs well as vertical columns and horizontal rows. Low level problems may be easy, but high level problems are a little difficult.ĭo you want to try Sudoku (Number Place) for the first time, or 9x9 Sudoku(Number Place) seems a little difficult, or do you want to make your kid smart, develop their thinking ability, or do you just want to play an easy puzzle without thinking so much, or are you bored with 9x9 Sudoku?
0 Comments
Leave a Reply. |