Create sudoku in java, JAVA Programming

Assignment Help:

The SudCell Class

A single cell in a Sudoku must clearly represent a number from 1 to 9.  But in a solver context, we need much more.  It isn't enough to say "this cell contains a 6" or "this cell is not yet determined and is temporarily blank."  We must have a way to express "this cell has not been determined, but I have ruled out all numbers except for 3, 5 and 8".  Similarly, we might need to say, "so far, I have not ruled out any digits for this cell.  It might be any of the nine digits as far as I know, 1, 2, 3, ..., 7, 8, 9."  Also, you might need to say, "this cell must be the number 6 - I know that for a fact."  You might want to stop reading for a moment to see if you can think of a clean way to represent such a constellation of sentiments in a single intrinsic or user-defined data type.

We will let a SudCell consist, at least partly of an array of nine booleans.  If the first boolean is true, that means this cell might still be 1 and if it is false, it means we have ruled out 1 for this cell. Similarly, the second boolean will be true or false depending on whether the number 2 is a possibility for this cell.  Here are some examples, conceptually.

Cell could be any number, 1 - 9:

true

true

true

true

true

true

true

true

true

Cell must be the number 4

false

false

false

true

false

false

false

false

false

Cell could be 3, 4, or 9:

false

false

true

true

false

false

false

false

true

Initially, when a new Sudoku puzzle is presented, each SudCell will look like one of the top two demonstrated, above, namely, either we know nothing about the cell (it is blank so all booleans in the cell array are true), or we know the final value, because it is given as part of the initial state of the puzzle (it contains one true and the rest false).

You will quickly discover that even this isn't enough information for the higher level classes to have.  They will need to distinguish "this cell must be the number 4, but I just discovered that fact" from "this cell must be the number 4, but I've known about that fact for a long time and have already exploited it."  We will call this attribute "completed" so that a cell that has only one true and all the rest false can be either completed (fact exploited and known for some time) or not completed (the fact that it is now uniquely determined has just been discovered and has not been used yet).  So we will have a boolean completed to reflect this information.  All you need to know for this class, though, is that we have a boolean completed that needs an accessor and mutator.

For those of you who are intent on designing your own solution from the ground up, keep the following in mind, with respect to the SudCell class:

  1. You must have a class called SudCell that encapsulates the minimal characteristics of a Sudoku cell.  Call it SudCell so I know where to find this class.
  2. SudCell should not anticipate any fancy logic of your other classes. What I have provided is enough to solve any Sudoku using any algorithm if you build your larger class on top of this.  I don't want a bunch of data and methods included in SudCell that can only be used in your unique, strange and wonderful higher-level classes.  That turns SudCell into a heavy weight class that does not fit well with most other Sudoku classes that others might design.
  3. If you can think of extra members or methods that you can argue are of good generality, you can add them.  However, keep item 2, above, in mind.  They must not contain unnecessary solution logic. The completed member represents a necessary and sufficient tool for higher level solution logic, but I can imagine other possible members (or methods) you can add, if it really makes sense.  It's hard to put a limit on this, but adding five more members would clearly be wrong, while adding one or two could be acceptable.
  4. This is not a linked list assignment, so please don't turn it into one.  Any additional members should not be used for that purpose.  Today, we are going to use multi-dimensional arrays, pointers and recursion to solve this, which means we don't need list structures.

Related Discussions:- Create sudoku in java

What is the output of the following javascript code, What is the output of ...

What is the output of the following JavaScript code? name="Ali Akbar"; document.write(name.charAt(4)) ;

Create an interface with a method concatenation, a)  Using Java, create an ...

a)  Using Java, create an interface with a method called concatenation which will be implemented in the class patient in part b. b)  Using Java, write the class patient with the

Streaming and decorator construction in java i/o, Java output and input is ...

Java output and input is described in terms of an abstract concept named a " stream ", which is a sequence of data. There are 2 types of streams. 1.      Byte streams (8 bit

How we use a car object in a different class, How we Use a Car object in a ...

How we Use a Car object in a different class ? class Car { String licensePlate; // e.g. "New York 543 A23" double speed; // in kilometers per hour double maxSpeed;

Explain how java allows the constraints on a generic type, Consider the fol...

Consider the following C++ template class. #include using namespace std; template class SortedList { public: SortedList() {size = 0;} void insert(T item); friend ostrea

What are checked and unchecked exception, What are Checked and UnChecked Ex...

What are Checked and UnChecked Exception? A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses. Making a

Catch clause should be used to handle the exception, How does a try statem...

How does a try statement determine which catch clause should be used to handle the exception?

Create a usercontrol called loginpasswordusercontrol, (Login User Control) ...

(Login User Control) Create a UserControl called LoginPasswordUserControl that contains a Label (loginLabel) that displays string "Login:", a TextBox (loginTextBox), where the user

Find representative skyline points in to 2 dimensional data, Find represent...

Find representative skyline points in to two dimensional data Project Description: Run skyline algorithm run representative skyline algorithm up to skyline algorithm (Affi

Change encrypted hsql database into csv format, Change encrypted HSQL datab...

Change encrypted HSQL database into CSV format Project Description: We have an encrypted HSQL Database which we have to convert into csv format. HSQL DB . We have java app

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd