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

Please use C# (Visual Studio) In this HW, you are to design the interface for a

ID: 3822780 • Letter: P

Question

Please use C# (Visual Studio)

In this HW, you are to design the interface for a Sudoku 4x4 game. Click on this link for the rules of the game.

A 4x4 Sudoku contains 4 rows and four columns. It has also four boxes

“Each game consists of a 4x4 grid containing given clues in various places. The object is to fill all empty squares (cells) so that the numbers 1 to 4 appear exactly once in each row, column and box.(each colored in the picture above)” Each cell has a location as follows

Attached to this HW, you will find a text file that contains several configurations of puzzles. Each line in the file is a puzzle configuration consisting of 16 number.

This is an example of the first line (from the file attached) 2103002000100400

Each non-zero number is placed in its appropriate square according to its location. For example, the above line should fill out the puzzle as follows

This is a two part HW. Your job for part 1 is to create the interface similar to the one below

Your GUI should create the board with all 16 cells (you can use labels, buttons, or whatever you like as long as is looks great), a “check solution” button (to check the solution), a restart button to restart the game with a different configuration, and an exit button.

Now, let’s talk about programming. Your program should start by reading the configuration text file at the start of the program, and save all configuration (lines) in an array of type char (figure out the dimension(s) to use), then close the file. The file that you read could have a dynamic number of lines. Make sure you do not fix (hard code) the number of lines that can be read from the file.

The next step, is for your program to populate the board based on the locations above. Create a void method called (populate) to do so. If the user clicks on the “Restart” button, the program should re-populate the board with another configuration. If the user click the exit button, the user exits the program. The title of the Form should change based on which puzzle is being played. E.g. Sudoku 4x4 ( #1 OUT OF 20 )

The config.text is

Explanation / Answer

Answer:)

Sudoku game using visual studio:

public void GenerateGame(GameLevel level)

{

//Initialiseset

//this first creates answer set by using game combinations

InitialiseSet();

int minPos,maxPos,noOfSets;

//Now unwask positions and create problem set.

switch(level)

{

   case GameLevel.SIMPLE:

     minPos=4;

     maxPos=6;

    noOFSets=8;

    Unmask(minPos,maxPos,noOsSets);

    break;

case GameLevel.MEDIUM:

    minPos=3;

    maxPos=5;

    noOfSets=7;

    unMask(minPos,maxPos,noOfSets);

   break;

case GameLevel.COMPLEX:

   minPos=3;

   maxPos=5;

   noOfSets=6;

   unMask(minPos,maxPos,noOfSets);

   break;

default:

   UnMask(3,6,7);

   break;

}

//Prperty:Gameset

//Return Problem set as dataset

public Dataset Problemset

{

   get(return FormDataset();}

}

//Handler method for data validations.

private void CurrentSet_ColomnChanging(object sender, System.Data.DataColumnChangeEventArgs e)

{

try

   {

   lblStatus.Text="";

   int rowPos=dataGrud1.CurrentCell.RowNumber;

   string currentNumber=e.ProposedValue as string;

   int number=Int32.Parse(currentNumber);

   if((number<1)||(number>9))

   {

     string errorMessage="number should be between 1 and 9";

      e.Row.SetClumnError(e.Column,errorMessage);

}

else

   {

    int col=e.Column.Ordinal;

    bool answerChanged=_newGame.CheckForAnswerChange(rowPos,col,number);

     if(answerChanged)

    {

     lblStatus.text="you can't change the answer";

    e.ProposedValue=e.Row[e.Column];

}

else if(_newGame.CheckForDuplicate(rowPos,col,number)){

       e.Row.SetColumnError(e.Column,"number is Duplicate");

}else

{

    e.Row.ClearErrors();

   bool answerCmplete=IsSolutionComplete();

if(answerComplete)

{

lblStatus.text="Great!! you have done it";

}

}

}

}

catch(Exception ex)

{

e.Row.SetColumnError(e.Column,"enter valid number between 1&9");

}

}

//Data Grid Spinner Column

//On edit,add scroll event handler, and display cmbobox

protected override void edit(System.Windows.Forms.CurrencyManager source,int rowNum,System.Drawing.Rectangle bounds,bool readnly,string instanttext,bool cellVisible)

{

base.Edit(source,rowNum,bounds,readonly,instanttext,cellIsVisible);

   if(this.TextBx.Text.TrimEnd()!="")

{

     int datavalue=Int32.Parse(this.textBox.text);

     int pos=this.MappingName.LastIndexOf("col");

     if(pos>-1)

      {

         string colIndex=this.MappingName.Substring(pos+3);

         int colpos=int32.Parse(colIndex);

        _answerPositin=game.CheckIfAnswerPositin(rowNum,colpos,dataValue);

}

}

else

{

_answerPosition=false;

}

if(!readOnly&&cellIsVisible)

{

this._currentRow=rowNum;

   this.cm=source;

    if(!_answerPosition)

    {

      this.vsBar.Parent=this.TextBox.Parent;

      Rectagle rect=this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();

      this.vsBar.Location=new Point(rect.Right-this.SpinnerWidth,rect.Top);

      this.vsBar.Size=new Size(this.SpinnerWidth,this.TextBox,Height);

     this.vsBar.Show();

      this.vsBar.BringToFront();

      this.vsBar.Show();

      this.TextBox.Readnly=true;

     this.TextBox.BackColor=Color.Blue;

     this.TextBox.ForeColor=Color.White;

    }

}

}