예제 #1
0
        static void handleQueue()
        {
            //Method checks the waitingForUpdate Queue, and updates all sudokuFields stored within
            //Also prints the new fields to MainWindow
            //This is the only method that should access field.updateField()!
            //If singleStep is set to true, only a single field will be fixed
            while (waitingForUpdate.Count > 0)
            {
                //Insert number in code and GUI
                sudokuField currentField = waitingForUpdate.Dequeue();
                currentField.updateField();

                if (sudokuIsInvalid())
                {
                    throw new InvalidOperationException("Something went wrong. Make sure you entered a valid sudoku");
                }

                MainWindow.sudokuTextBoxes[Array.IndexOf(fields, currentField)].Text = (currentField.getNumber() + 1).ToString();
                solvedFields += 1;

                //Updates the candidates of surrounding fields
                sudokuField[] surroundingFields = getSurroundings(currentField);

                foreach (sudokuField f in surroundingFields)
                {
                    removeCandidate(f, currentField.getNumber());
                }

                //Exit method if only one field is wanted
                if (singleField)
                {
                    return;
                }
            }
        }
예제 #2
0
        static void handleQueue()
        {
            //Method checks the waitingForUpdate Queue, and updates all sudokuFields stored within
            //Also prints the new fields to Form1
            while (waitingForUpdate.Count > 0)
            {
                sudokuField fieldInQueue = waitingForUpdate.Dequeue();
                fieldInQueue.updateField();
                Form1.sudokuTextBoxes[Array.IndexOf(fields, fieldInQueue)].Text = (fieldInQueue.getNumber() + 1).ToString();

                //Updates the candidates of surrounding fields
                sudokuField[] surroundingFields = getSurroundings(fieldInQueue);

                foreach (sudokuField f in surroundingFields)
                {
                    removeCandidate(f, fieldInQueue.getNumber());
                }
            }
        }