Beispiel #1
0
        /**
         * @method getTrialsNumber is going through the process of getting the number of trials to
         *              run either the non-intelligent or intelligent algorithm.
         */
        private int getTrialsNumber()
        {
            int trialsNumber;

            // First, record number of trials the user has chosen
            bool isMultiTrial = Int32.TryParse(DialogInput.promptDialog("How many trials: ", "Choose the number of tours."), out trialsNumber);

            // Double check to see if user entered a number or not
            if (!isMultiTrial)
            {
                MessageBox.Show("Error: Cannot read number of trials input. \nDefaulting to 1 trial", "Trial Choice Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                trialsNumber = 1; // default is one trial
            }

            return(trialsNumber);
        }
Beispiel #2
0
        /**
         * @method setRowCol creates a dialog prompt to ask the user of the knight's
         *          starting position and returns a new Knight object to that choice.
         */
        private Knight setRowCol(int trials)
        {
            // Starting position will be asked for each trial
            var startingPos = DialogInput.promptDialog("Row, Column: ", "Choose your knight's starting position - Trial " + trials);

            // Next, splitting row & column numbers entered only if comma was delimited
            var  rowcol = startingPos.Split(',');
            byte row, col;

            // Then we need to test the row and column inputs to see if they're an actual cell to set the knight at.
            if (Byte.TryParse(rowcol[0], out row) && Byte.TryParse(rowcol[1], out col) && row < 8 && col < 8 && row >= 0 && col >= 0)
            {
                return(new Knight(row, col));
            }
            else
            {
                MessageBox.Show("Error: Cannot read row,column input. \nDefaulting to cell 0,0", "Row/Column Choice Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(new Knight(0, 0));
            }
        } // end of setRowCol()