private void btnNewGame_Click(object sender, EventArgs e) { var result = MessageBox.Show("Are you sure you would like to start a new game?", "New Game", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.OK) { UIHelpers.CloseOpenWindows(); UIHelpers.ClearControls(this.Controls); _pencilMarks = new Canidates(); _setup = new ControlLogic.SetupPuzzle(_difficultySelection); _setup.UpdateCanidates(); puzzleReady = false; _difficultySelection = cmboxDifficulty.SelectedIndex; _userAnswers = new PuzzleNine(1); fillSetupPuzzle(); puzzleReady = true; _userAnswers.ResetCoordinates(); combineTruthSetupAndUsers(); toolStrip.Text = "Good luck and have fun!"; } }
public PuzzleNine LoadSavedPuzzle() { List <int[, ]> puzzlesToLoad = null; PuzzleNine userAnswers = new PuzzleNine(1); try { DataAccessor dataAccessor = new DataAccessor(); puzzlesToLoad = dataAccessor.RetrieveSaveSolAndSetup(); } catch (Exception ex) { throw new ApplicationException("Data not availiable.", ex); } if (puzzlesToLoad != null) { // save data contains a solution, a setup, and user answers puzzleSolution = new PuzzleNine(); puzzleSolution._puzzle = puzzlesToLoad[0]; setupPuzzle = puzzleSolution.CopyPuzzle(); //basically the same as the buildPuzzle method setupPuzzle._puzzle = puzzlesToLoad[1]; UpdateCanidates(); userAnswers._puzzle = puzzlesToLoad[2]; } return(userAnswers); }
public Solver(PuzzleNine puzzle) { // make sure that it is creating a new object and not passing a reference _puzzleObject = puzzle.CopyPuzzle(); _puzzleObject.ResetCoordinates(); _puzzleObject.UpdateCoordinates(); findPossibleAnswers(); SinglePosition(); }
public SetupPuzzle(int difficultySelection) { puzzleSolution = new PuzzleNine(); //copy the puzzle setupPuzzle = puzzleSolution.CopyPuzzle(); // take numbers out of the puzzle buildPuzzle(difficultySelection); setupPuzzle.UpdateCoordinates(); }
public SaveLoad() { _setupPuzzle = new SetupPuzzle(); _userAnswers = new PuzzleNine(1); }