Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M9522379

Have any Question?


Related Questions in Java

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As