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(); }