コード例 #1
0
ファイル: Trivia.cs プロジェクト: anitaleung/hunt-the-wumpus
       // Ask trivia questions
        private void AskOneQuestion()
        {
            Random r = new Random();
            int indexofrightanswer = r.Next(4) + 1; // Generate random number between 1 and 3
            int numberofqstoask = caveNumber * 10;
            numberofqstoask += askedquestion[caveNumber];
            TriviaUI ui = new TriviaUI(this, indexofrightanswer);
            ui.SetQuestion(questionList[numberofqstoask, 0]);
            // Now ask the question
            ui.SetAnswer1(indexofrightanswer == 1 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, indexofrightanswer]);
            ui.SetAnswer2(indexofrightanswer == 2 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, 2]);
            ui.SetAnswer3(indexofrightanswer == 3 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, 3]);
            ui.SetAnswer4(indexofrightanswer == 4 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, 4]);
            askedquestion[caveNumber] += 1; // Count up number of questions asked
            numberofqsaskedround--; // Count down question round already asked
            ui.ShowDialog(); // Show the trivia UI

        }
コード例 #2
0
        // Ask trivia questions
        private void AskOneQuestion()
        {
            Random r = new Random();
            int    indexofrightanswer = r.Next(4) + 1; // Generate random number between 1 and 3
            int    numberofqstoask    = caveNumber * 10;

            numberofqstoask += askedquestion[caveNumber];
            TriviaUI ui = new TriviaUI(this, indexofrightanswer);

            ui.SetQuestion(questionList[numberofqstoask, 0]);
            // Now ask the question
            ui.SetAnswer1(indexofrightanswer == 1 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, indexofrightanswer]);
            ui.SetAnswer2(indexofrightanswer == 2 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, 2]);
            ui.SetAnswer3(indexofrightanswer == 3 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, 3]);
            ui.SetAnswer4(indexofrightanswer == 4 ? questionList[numberofqstoask, 1] : questionList[numberofqstoask, 4]);
            askedquestion[caveNumber] += 1; // Count up number of questions asked
            numberofqsaskedround--;         // Count down question round already asked
            ui.ShowDialog();                // Show the trivia UI
        }
コード例 #3
0
        private void askQuestion()
        {
            // Generate random number between 1 and 4
            Random r = new Random();
            int indexofrightanswer = r.Next(4) + 1;

            int numberofqstoask = caveNumber * 10;
            numberofqstoask += askedquestion[caveNumber];

            TriviaUI ui = new TriviaUI(this, indexofrightanswer);
            ui.SetQuestion(questionlist[numberofqstoask, 0]);

            // Now ask the question
            ui.SetAnswer1(indexofrightanswer == 1 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, indexofrightanswer]);
            ui.SetAnswer2(indexofrightanswer == 2 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, 2]);
            ui.SetAnswer3(indexofrightanswer == 3 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, 3]);
            ui.SetAnswer4(indexofrightanswer == 4 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, 4]);
            askedquestion[caveNumber] += 1;
            numberofqsaskedround--;
            ui.ShowDialog();

        }
コード例 #4
0
        private void askQuestion()
        {
            // Generate random number between 1 and 4
            Random r = new Random();
            int    indexofrightanswer = r.Next(4) + 1;

            int numberofqstoask = caveNumber * 10;

            numberofqstoask += askedquestion[caveNumber];

            TriviaUI ui = new TriviaUI(this, indexofrightanswer);

            ui.SetQuestion(questionlist[numberofqstoask, 0]);

            // Now ask the question
            ui.SetAnswer1(indexofrightanswer == 1 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, indexofrightanswer]);
            ui.SetAnswer2(indexofrightanswer == 2 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, 2]);
            ui.SetAnswer3(indexofrightanswer == 3 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, 3]);
            ui.SetAnswer4(indexofrightanswer == 4 ? questionlist[numberofqstoask, 1] : questionlist[numberofqstoask, 4]);
            askedquestion[caveNumber] += 1;
            numberofqsaskedround--;
            ui.ShowDialog();
        }