/** * Load puzzle from provided puzzle examples. * @see SudokuPuzzles * @see SudokuStore#getPuzzleExample(int) */ private void loadFromExample() { JanetConsole.println(); JanetConsole.print("Please provide example number (between 0 and " + (SudokuPuzzles.NUMBER_OF_PUZZLE_EXAMPLES - 1) + "): "); int example = JanetConsole.readInt(); if ((example >= 0) && (example < SudokuPuzzles.NUMBER_OF_PUZZLE_EXAMPLES)) { JanetConsole.println("Loading example: " + example); trackPuzzleUndo(); puzzle = SudokuStore.boardCopy(SudokuStore.getPuzzleExample(example)); } else { JanetConsole.println(">>> !!! Incorrect example number !!! <<<"); } }
/** * Ask user for menu item selection. * @return Select item id {@link MenuData}. * * @see MenuData */ internal int getItem() { int selItem = 0; bool loop = true; do { consolePrintMenue(); JanetConsole.println(); JanetConsole.print("Your selection: "); selItem = JanetConsole.readInt(); if ((selItem >= 0) && (selItem <= itemsNum)) { loop = false; } else { JanetConsole.println(">>> !!! Please select correct menu item. !!! <<<"); } } while (loop == true); return(selItem); }
/** * Manually sets cell value. */ private void setCell() { JanetConsole.print(" Row number (between 1 and 9): "); int row = JanetConsole.readInt(); if ((row < 1) || (row > 9)) { JanetConsole.println(">>> !!! Error - incorrect row number !!! <<<"); return; } JanetConsole.print("Column number (between 1 and 9): "); int col = JanetConsole.readInt(); if ((col < 1) || (col > 9)) { JanetConsole.println(">>> !!! Error - incorrect column number !!! <<<"); return; } JanetConsole.print(" Digit (between 0 and 9): "); int digit = JanetConsole.readInt(); if ((digit < 0) || (digit > 9)) { JanetConsole.println(">>> !!! Error - incorrect digit !!! <<<"); return; } trackPuzzleUndo(); puzzle[row - 1, col - 1] = digit; }