Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m in java one and need help with this code. please follow the givne direction

ID: 3693359 • Letter: I

Question

I'm in java one and need help with this code. please follow the givne directions and test your program to make sure it works as it is required. I will apreciate your help.please follow stept by step the given directions. thank you.

Here are two correct 4x4 Sudoku grids:

  

3

2

4

1

4

1

3

2

1

4

2

3

2

3

1

4

4x4 Sudoku Example #1

1

2

3

4

3

4

1

2

2

1

4

3

4

3

2

1

4x4 Sudoku Example #2

Notice how each row, column and region has the individual numbers from 1 through 4 used only once. This means that the values used in each row, column and region must add up to 10 (1 + 2 + 3 + 4). This is how we will check our 4x4 Sudoku grids for this assignment.

Allow your user to enter their Sudoku grids row-by-row, separating each of the four values by a space and hitting ENTER at the end of the row.

When the user has entered all 16 values into the program, you should output validation checks for each region, row and column. An example run can be seen below with sample user input underlined.

This program checks simple, small, 4x4 Sudoku grids for correctness. Each column, row and 2x2 region contains the numbers 1 through 4 only once.

To check your Sudoku, enter your board one row at a time, with each digit separated by a space. Hit ENTER at the end of a row.

SUDO:VALID

Your program does not have to check for the numbers 1 through 4 being used uniquely in each row, column and region. In other words, don't worry about validating their input to make sure they only enter the digits 1, 2, 3 or 4 and only enter them once per row, column and region. At this point in the semester, writing data validation like that would be incredibly painful.

You simply need to check that each row, column and region adds up to 10.

This simplistic type of checking will, however, allow some bad Sudoku grids to be validated as good. See two examples of this below. For this program, we will let these instances slide and not worry about them.

4

1

1

4

1

4

4

1

1

4

4

1

4

1

1

4

Invalid 4x4 Sudoku That Will Be Labeled as valid, Example #1

10

0

0

0

0

0

10

0

0

10

0

0

0

0

0

10

Invalid 4x4 Sudoku That Will Be Labeled as valid, Example #2

Rows, columns and regions are identified as found below:

ROW1

ROW2

ROW3

ROW4

C

O

L

1

C

O

L

2

C

O

L

3

C

O

L

4

REGION

1

REGION

3

REGION

2

REGUON

4

When producing your output, you must first validate the regions, then the rows and then the columns. Each region, row and column validation should appear on a line by itself using the identifiers REG-1, REG-2, REG-3, REG-4, ROW-1, ROW-2, ROW-3, ROW-4, COL-1, COL-2, COL-3, and COL-4.

Each identifier will be followed immediately by a colon and that colon will be followed immediately by the word GOOD or the word BAD depending on if that row/column/region passes or fails validation.

The final line of output should be the keyword SUDO, followed immediately by a colon, followed immediately by either the word VALID or the word INVALID.

Please see the example run and run the sample program a number of times to make sure you understand how output is expected to be displayed for this program.

UML DIAGRAM FOR CLASS NetID_SudokuChecker
Create a class based on your UNO NetID. Replace NetID in the following example with your UNO NetID.

«constructor» NetID_SudokuChecker ( )

+ displayGrid ( )
+ getGrid ( )
+ checkGrid ( )

DISCUSSION OF CLASS NetID_SudokuChekcer
What follows is a short description of what each data member represents and what each method does:

grid

grid is a private data member that is a 4x4 array of integers. It will store the four rows of four items in each row.

This is the constructor. It should display welcome greetings, explaining the rules of the 4x4 Sudoku grid we're processing.

getGrid()

This public method should read the Sudoku grid from the user row by row, using spaces between values in each row.

This public method simply displays the grid to the screen in a nice, square pattern.

This public method uses the private data member grid to test whether or not the given values are a valid Sudoku grid.

Your method does not have to check for the numbers 1 through 4 being used uniquely in each row, column and region. In other words, don't worry about validating their input to make sure they only enter the digits 1, 2, 3 or 4 and only enter them once per row, column and region. You can add this functionality, but it is not required.

When producing your output, you must first validate the regions, then the rows and then the columns. Each region, row and column validation should appear on a line by itself using the identifiers REG-1, REG-2, REG-3, REG-4, ROW-1, ROW-2, ROW-3, ROW-4, COL-1, COL-2, COL-3, and COL-4.

Each identifier will be followed immediately by a colon and that colon will be followed immediately by the word GOOD or the word BAD depending on if that row/column/region passes or fails validation.

The final line of output should be the keyword SUDO, followed immediately by a colon, followed immediately by either the word VALID or the word INVALID.

Make sure your spelling and formatting for each of the above is correct.

DISCUSSION OF THE FILE NetID_SudokuChecker.java
You will need to implement your class methods in the file NetID_SudokuChecker.java. This file should follow the basic outline here:

import java.util.Scanner;
public class NetID_SudokuChecker {

A MAIN / TEST PROGRAM (NetID_SudokuCheckerTest.java)

To test your implementation of the NetID_SudokuChecker class, use the following code for NetID_SudokuCheckerTest.java,changing NetID to your UNO NetID.

public class NetID_SudokuCheckerTest

{

public static void main ( String args[] )

{

NetID_SudokuChecker sudChecker = new NetID_SudokuChecker();

}

}

SUMMARY OF FILES

You will need to create two files for this assignment:

. NetID_SudokuChecker.java, which will be modeled after the code example seen at the top of this page.

. NetID_SudokuCheckerTest.java, which will contain the code exactly as seen above.

Essentially, you will type in the code exactly as seen in this assignment for both files. You will then plug in the appropriate code into the methods of the NetID_SudokuChecker.java file.

DO NOT CHANGE THE NAMES OF ANY OF THE methods OR THE CLASS ITSELF!!!!!

Goals

Implement a moderately straightforward class that creates three methods (a constructor and two other methods) to implement a Sudoku- checking data type using a UML specification as a guideline for creation of the class.

Points to Think About

Try compiling your class often, after adding maybe five or ten lines of code to your program. By doing this, you’re less likely to have dozens of errors to have to fix after compilation.

You may wish to set up the instance variable and shells for the methods themselves first and compile that code without any real code inside any of the methods. You can also set up the Tester class and try compiling that against your compiled SudokuChecker class.

Then, go back and start filling in code for each of the methods in the SudokuChecker class.

Grading Notes

>> Method documentation is required for all methods other than main()and you must follow the Program Coding Standards handout posted to Blackboard for this course. Points will be deducted for missing or incomplete method documentation.

>> Your methods must behave as outlined in this assignment.

>> Make sure your output follows the format you see in the example solution provided. A portion of your grade is for following this format exactly. If you messed up some of the output on your previous Sudoku solution, now is the time to fix it.

Output Example

Sample Run (user input is underlined)

This program checks simple, small, 4x4 Sudoku grids for correctness. Each column, row and 2x2 region contains the numbers 1 through 4 only once.

To check your Sudoku, enter your board one row at a time, with each digit separated by a space. Hit ENTER at the end of a row.

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

EnterRow1:1 2 3 4

EnterRow2:3 4 2 1

EnterRow3:1 2 3 4

EnterRow4:4 3 2 1

1 2 3 4

3 4 2 1

1 2 3 4

4 3 2 1

Thank you. Now checking ...

sample output run 2

Welcome to the Sudoku Checker v1.0!

This program checks simple, small, 4x4 Sudoku grids for correctness. Each column, row and 2x2 region contains the numbers 1 through 4 only once.

To check your Sudoku, enter your board one row at a time, with each digit separated by a space. Hit ENTER at the end of a row.

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

EnterRow1: 3 2 4 1

EnterRow2: 4 1 3 2

EnterRow3: 1 4 2 3

EnterRow4: 2 3 1 4

3 2 4 1

4 1 3 2

1 4 2 3

2 3 1 4

Thank you. Now checking ...

SUDO:VALID

3

2

4

1

4

1

3

2

1

4

2

3

2

3

1

4

Explanation / Answer

import java.awt.*; // Uses AWT's Layout Managers import java.awt.event.*; // Uses AWT's Event Handlers import javax.swing.*; // Uses Swing's Container/Components /** * The Sudoku game. * To solve the number puzzle, each row, each column, and each of the * nine 3×3 sub-grids shall contain all of the digits from 1 to 9 */ public class Sudoku extends JFrame { // Name-constants for the game properties public static final int GRID_SIZE = 9; // Size of the board public static final int SUBGRID_SIZE = 3; // Size of the sub-grid // Name-constants for UI control (sizes, colors and fonts) public static final int CELL_SIZE = 60; // Cell width/height in pixels public static final int CANVAS_WIDTH = CELL_SIZE * GRID_SIZE; public static final int CANVAS_HEIGHT = CELL_SIZE * GRID_SIZE; // Board width/height in pixels public static final Color OPEN_CELL_BGCOLOR = Color.YELLOW; public static final Color OPEN_CELL_TEXT_YES = new Color(0, 255, 0); // RGB public static final Color OPEN_CELL_TEXT_NO = Color.RED; public static final Color CLOSED_CELL_BGCOLOR = new Color(240, 240, 240); // RGB public static final Color CLOSED_CELL_TEXT = Color.BLACK; public static final Font FONT_NUMBERS = new Font("Monospaced", Font.BOLD, 20); // The game board composes of 9x9 JTextFields, // each containing String "1" to "9", or empty String private JTextField[][] tfCells = new JTextField[GRID_SIZE][GRID_SIZE]; // Puzzle to be solved and the mask (which can be used to control the // difficulty level). // Hardcoded here. Extra credit for automatic puzzle generation // with various difficulty levels. private int[][] puzzle = {{5, 3, 4, 6, 7, 8, 9, 1, 2}, {6, 7, 2, 1, 9, 5, 3, 4, 8}, {1, 9, 8, 3, 4, 2, 5, 6, 7}, {8, 5, 9, 7, 6, 1, 4, 2, 3}, {4, 2, 6, 8, 5, 3, 7, 9, 1}, {7, 1, 3, 9, 2, 4, 8, 5, 6}, {9, 6, 1, 5, 3, 7, 2, 8, 4}, {2, 8, 7, 4, 1, 9, 6, 3, 5}, {3, 4, 5, 2, 8, 6, 1, 7, 9}}; // For testing, open only 2 cells. private boolean[][] masks = {{false, false, false, false, false, true, false, false, false}, {false, false, false, false, false, false, false, false, true}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}}; /** * Constructor to setup the game and the UI Components */ public Sudoku() { Container cp = getContentPane(); cp.setLayout(new GridLayout(GRID_SIZE, GRID_SIZE)); // 9x9 GridLayout // Allocate a common listener as the ActionEvent listener for all the // JTextFields // ... [TODO 3] (Later) .... // Construct 9x9 JTextFields and add to the content-pane for (int row = 0; row
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote