Exemplo n.º 1
0
        /*
         * ========================================
         *               Input Menu
         * ========================================
         */
        /**
         * Input menu loop
         */
        private void loopMenuInput()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.INPUT_TITLE, MenuData.INPUT_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.INPUT_ONE_LINE: inputPuzzleFromKeyboard1Line(); break;

                case MenuData.INPUT_9ROWS: inputPuzzleFromKeyboard9rows(); break;

                case MenuData.INPUT_11ROWS: inputPuzzleFromKeyboard11rows(); break;

                case MenuData.INPUT_13ROWS: inputPuzzleFromKeyboard13rows(); break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 2
0
        /*
         * ========================================
         *             Generate Menu
         * ========================================
         */
        /**
         * Generate menu loop.
         */
        private void loopMenuGenerate()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.GENERATE_TITLE, MenuData.GENERATE_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.GENERATE_RANDOM: generateRandomPuzzle(); break;

                case MenuData.GENERATE_RANDOM_PLUS_RATING: generateAndRateRandomPuzzle(); break;

                case MenuData.GENERATE_BASED_ON_EXAMPLE: generateFromExample(); break;

                case MenuData.GENERATE_BASED_ON_CURRENT_PUZZLE: generateFromCurrentPuzzle(); break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 3
0
        /*
         * ========================================
         *                Load Menu
         * ========================================
         */
        /**
         * Load menu loop.
         */
        private void loopMenuLoad()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.LOAD_TITLE, MenuData.LOAD_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.LOAD_FROM_FILE: loadFromFile(); break;

                case MenuData.LOAD_EXAMPLE: loadFromExample(); break;

                case MenuData.LOAD_EMPTY_PUZZLE: trackPuzzleUndo(); puzzle = SudokuStore.boardCopy(SudokuPuzzles.PUZZLE_EMPTY); break;

                case MenuData.LOAD_LIST_EXAMPLES: listPuzzleExamples(); break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 4
0
        /*
         * ========================================
         *             Options Menu
         * ========================================
         */
        /**
         * Options menu loop
         */
        private void loopMenuOptions()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.OPTIONS_TITLE, MenuData.OPTIONS_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.OPTIONS_RND_SEED_ON_EMPTY_CELL: rndSeedOnCells = !rndSeedOnCells; break;

                case MenuData.OPTIONS_RND_SEED_ON_FREE_DIGIT: rndSeedOnDigits = !rndSeedOnDigits; break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 5
0
        /*
         * ========================================
         *             Solve Menu
         * ========================================
         */
        /**
         * Solve menu loop
         */
        private void loopMenuSolve()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.SOLVE_TITLE, MenuData.SOLVE_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.SOLVE_FIND_FIRST: solveFindFirst(); break;

                case MenuData.SOLVE_FIND_ALL: solveFindAll(); break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 6
0
        /*
         * ========================================
         *              Evaluate Menu
         * ========================================
         */
        /**
         * Evaluate menu loop
         */
        private void loopMenuEvaluate()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.EVALUATE_TITLE, MenuData.EVALUATE_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.EVALUATE_SOLUTION_EXISTENCE: evaluateSolutions(); break;

                case MenuData.EVALUATE_PUZZLE_DIFFICULTY: ratePuzzleDifficulty(); break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 7
0
        /*
         * ========================================
         *                Main Menu
         * ========================================
         */
        /**
         * Main menu loop
         */
        private void loopMenuMain()
        {
            Menu menu = new Menu(MenuData.MAIN_TITLE, MenuData.MAIN_CONTENT, this);
            int  selItem;

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.LOAD: loopMenuLoad(); break;

                case MenuData.GENERATE: loopMenuGenerate(); break;

                case MenuData.INPUT: loopMenuInput(); break;

                case MenuData.MODIFY: loopMenuModify(); break;

                case MenuData.EVALUATE: loopMenuEvaluate(); break;

                case MenuData.SOLVE: loopMenuSolve(); break;

                case MenuData.SAVE: savePuzzle(); break;

                case MenuData.OPTIONS: loopMenuOptions(); break;

                case MenuData.ABOUT: displayAboutInto(); break;

                case MenuData.RETURN: quitFromApp(); break;

                case MenuData.UNDO: performPuzzleUndo(); break;

                case MenuData.REDO: performPuzzleRedo(); break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }
Exemplo n.º 8
0
		/*
		 * ========================================
		 *             Options Menu
		 * ========================================
		 */
		/**
		 * Options menu loop
		 */
		private void loopMenuOptions() {
			int selItem;
			Menu menu = new Menu(MenuData.OPTIONS_TITLE, MenuData.OPTIONS_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.OPTIONS_RND_SEED_ON_EMPTY_CELL: rndSeedOnCells = !rndSeedOnCells; break;
				case MenuData.OPTIONS_RND_SEED_ON_FREE_DIGIT: rndSeedOnDigits = !rndSeedOnDigits; break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 9
0
		/*
		 * ========================================
		 *              Modify Menu
		 * ========================================
		 */
		/**
		 * Modify menu loop
		 */
		private void loopMenuModify() {
			int selItem;
			Menu menu = new Menu(MenuData.MODIFY_TITLE, MenuData.MODIFY_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.MODIFY_SET_CELL:
					trackPuzzleUndo();
					setCell();
					break;
				case MenuData.MODIFY_ROTATE_CLOCK_WISE:
					trackPuzzleUndo();
					puzzle = SudokuStore.rotateClockWise(puzzle);
					break;
				case MenuData.MODIFY_ROTATE_COUNTER_CLOCK_WISE:
					trackPuzzleUndo();
					puzzle = SudokuStore.rotateCounterclockWise(puzzle);
					break;
				case MenuData.MODIFY_TRANSPOSE_TL_BR:
					trackPuzzleUndo();
					puzzle = SudokuStore.transposeTlBr(puzzle);
					break;
				case MenuData.MODIFY_TRANSPOSE_TR_BL:
					trackPuzzleUndo();
					puzzle = SudokuStore.transposeTrBl(puzzle);
					break;
				case MenuData.MODIFY_REFLECT_HORIZ:
					trackPuzzleUndo();
					puzzle = SudokuStore.reflectHorizontally(puzzle);
					break;
				case MenuData.MODIFY_REFLECT_VERT:
					trackPuzzleUndo();
					puzzle = SudokuStore.reflectVertically(puzzle);
					break;
				case MenuData.MODIFY_SWAP_COL_SEGMENTS:
					trackPuzzleUndo();
					puzzle = SudokuStore.swapColSegmentsRandomly(puzzle);
					break;
				case MenuData.MODIFY_SWAP_ROW_SEGMENTS:
					trackPuzzleUndo();
					puzzle = SudokuStore.swapRowSegmentsRandomly(puzzle);
					break;
				case MenuData.MODIFY_SWAP_COLS_IN_SEGMENTS:
					trackPuzzleUndo();
					puzzle = SudokuStore.swapColsInSegmentRandomly(puzzle);
					break;
				case MenuData.MODIFY_SWAP_ROWS_IN_SEGMENTS:
					trackPuzzleUndo();
					puzzle = SudokuStore.swapRowsInSegmentRandomly(puzzle);
					break;
				case MenuData.MODIFY_PERMUTE:
					trackPuzzleUndo();
					puzzle = SudokuStore.permuteBoard(puzzle);
					break;
				case MenuData.MODIFY_RANDOM_TRANSF_ONE:
					trackPuzzleUndo();
					puzzle = SudokuStore.randomBoardTransf(puzzle);
					break;
				case MenuData.MODIFY_RANDOM_TRANSF_SEQ:
					trackPuzzleUndo();
					puzzle = SudokuStore.seqOfRandomBoardTransf(puzzle);
					break;
				case MenuData.UNDO:
					performPuzzleUndo();
					break;
				case MenuData.REDO:
					performPuzzleRedo();
					break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 10
0
		/*
		 * ========================================
		 *             Solve Menu
		 * ========================================
		 */
		/**
		 * Solve menu loop
		 */
		private void loopMenuSolve() {
			int selItem;
			Menu menu = new Menu(MenuData.SOLVE_TITLE, MenuData.SOLVE_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.SOLVE_FIND_FIRST: solveFindFirst(); break;
				case MenuData.SOLVE_FIND_ALL: solveFindAll(); break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 11
0
		/*
		 * ========================================
		 *              Evaluate Menu
		 * ========================================
		 */
		/**
		 * Evaluate menu loop
		 */
		private void loopMenuEvaluate() {
			int selItem;
			Menu menu = new Menu(MenuData.EVALUATE_TITLE, MenuData.EVALUATE_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.EVALUATE_SOLUTION_EXISTENCE: evaluateSolutions(); break;
				case MenuData.EVALUATE_PUZZLE_DIFFICULTY: ratePuzzleDifficulty(); break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 12
0
		/*
		 * ========================================
		 *               Input Menu
		 * ========================================
		 */
		/**
		 * Input menu loop
		 */
		private void loopMenuInput() {
			int selItem;
			Menu menu = new Menu(MenuData.INPUT_TITLE, MenuData.INPUT_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.INPUT_ONE_LINE: inputPuzzleFromKeyboard1Line(); break;
				case MenuData.INPUT_9ROWS: inputPuzzleFromKeyboard9rows(); break;
				case MenuData.INPUT_11ROWS: inputPuzzleFromKeyboard11rows(); break;
				case MenuData.INPUT_13ROWS: inputPuzzleFromKeyboard13rows(); break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 13
0
		/*
		 * ========================================
		 *             Generate Menu
		 * ========================================
		 */
		/**
		 * Generate menu loop.
		 */
		private void loopMenuGenerate() {
			int selItem;
			Menu menu = new Menu(MenuData.GENERATE_TITLE, MenuData.GENERATE_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.GENERATE_RANDOM: generateRandomPuzzle(); break;
				case MenuData.GENERATE_RANDOM_PLUS_RATING: generateAndRateRandomPuzzle(); break;
				case MenuData.GENERATE_BASED_ON_EXAMPLE: generateFromExample(); break;
				case MenuData.GENERATE_BASED_ON_CURRENT_PUZZLE: generateFromCurrentPuzzle(); break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 14
0
		/*
		 * ========================================
		 *                Load Menu
		 * ========================================
		 */
		/**
		 * Load menu loop.
		 */
		private void loopMenuLoad() {
			int selItem;
			Menu menu = new Menu(MenuData.LOAD_TITLE, MenuData.LOAD_CONTENT, this);
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.LOAD_FROM_FILE: loadFromFile(); break;
				case MenuData.LOAD_EXAMPLE: loadFromExample(); break;
				case MenuData.LOAD_EMPTY_PUZZLE: trackPuzzleUndo(); puzzle = SudokuStore.boardCopy(SudokuPuzzles.PUZZLE_EMPTY); break;
				case MenuData.LOAD_LIST_EXAMPLES: listPuzzleExamples(); break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 15
0
		/*
		 * ========================================
		 *                Main Menu
		 * ========================================
		 */
		/**
		 * Main menu loop
		 */
		private void loopMenuMain() {
			Menu menu = new Menu(MenuData.MAIN_TITLE, MenuData.MAIN_CONTENT, this);
			int selItem;
			do {
				selItem = menu.getItem();
				switch (selItem) {
				case MenuData.LOAD: loopMenuLoad(); break;
				case MenuData.GENERATE: loopMenuGenerate(); break;
				case MenuData.INPUT: loopMenuInput(); break;
				case MenuData.MODIFY: loopMenuModify(); break;
				case MenuData.EVALUATE: loopMenuEvaluate(); break;
				case MenuData.SOLVE: loopMenuSolve(); break;
				case MenuData.SAVE: savePuzzle(); break;
				case MenuData.OPTIONS: loopMenuOptions(); break;
				case MenuData.ABOUT: displayAboutInto(); break;
				case MenuData.RETURN: quitFromApp(); break;
				case MenuData.UNDO: performPuzzleUndo(); break;
				case MenuData.REDO: performPuzzleRedo(); break;
				default: incorrectSelection(); break;
				}
			} while (selItem != MenuData.RETURN);
		}
Exemplo n.º 16
0
        /*
         * ========================================
         *              Modify Menu
         * ========================================
         */
        /**
         * Modify menu loop
         */
        private void loopMenuModify()
        {
            int  selItem;
            Menu menu = new Menu(MenuData.MODIFY_TITLE, MenuData.MODIFY_CONTENT, this);

            do
            {
                selItem = menu.getItem();
                switch (selItem)
                {
                case MenuData.MODIFY_SET_CELL:
                    trackPuzzleUndo();
                    setCell();
                    break;

                case MenuData.MODIFY_ROTATE_CLOCK_WISE:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.rotateClockWise(puzzle);
                    break;

                case MenuData.MODIFY_ROTATE_COUNTER_CLOCK_WISE:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.rotateCounterclockWise(puzzle);
                    break;

                case MenuData.MODIFY_TRANSPOSE_TL_BR:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.transposeTlBr(puzzle);
                    break;

                case MenuData.MODIFY_TRANSPOSE_TR_BL:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.transposeTrBl(puzzle);
                    break;

                case MenuData.MODIFY_REFLECT_HORIZ:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.reflectHorizontally(puzzle);
                    break;

                case MenuData.MODIFY_REFLECT_VERT:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.reflectVertically(puzzle);
                    break;

                case MenuData.MODIFY_SWAP_COL_SEGMENTS:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.swapColSegmentsRandomly(puzzle);
                    break;

                case MenuData.MODIFY_SWAP_ROW_SEGMENTS:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.swapRowSegmentsRandomly(puzzle);
                    break;

                case MenuData.MODIFY_SWAP_COLS_IN_SEGMENTS:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.swapColsInSegmentRandomly(puzzle);
                    break;

                case MenuData.MODIFY_SWAP_ROWS_IN_SEGMENTS:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.swapRowsInSegmentRandomly(puzzle);
                    break;

                case MenuData.MODIFY_PERMUTE:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.permuteBoard(puzzle);
                    break;

                case MenuData.MODIFY_RANDOM_TRANSF_ONE:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.randomBoardTransf(puzzle);
                    break;

                case MenuData.MODIFY_RANDOM_TRANSF_SEQ:
                    trackPuzzleUndo();
                    puzzle = SudokuStore.seqOfRandomBoardTransf(puzzle);
                    break;

                case MenuData.UNDO:
                    performPuzzleUndo();
                    break;

                case MenuData.REDO:
                    performPuzzleRedo();
                    break;

                default: incorrectSelection(); break;
                }
            } while (selItem != MenuData.RETURN);
        }