Esempio n. 1
0
 public bool VerifyAnswer(int userSelection, QuestionClass question)
 {
     if (question.CorrectAnswerIndex == userSelection)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        private int PlayRound(List <QuestionClass> questions, int questionIndex)
        {
            TotalPoints = 0;
            Game game = new Game();


            QuestionsAsked = 0;
            while (QuestionsAsked < RoundThreshold && questionIndex < QuestionLimit)
            {
                QuestionClass questionAsked = game.GetQuestion(questions, questionIndex);
                Console.WriteLine(game.PrintQuestion(questionAsked));


                var choices = game.PrintChoices(questionAsked);
                for (int i = 0; i < choices.Count; i++)
                {
                    Console.WriteLine("{0}. {1}", i + 1, choices[i]);
                }

                bool validEntry = false;
                while (!validEntry)
                {
                    Console.WriteLine("Please enter your choice 1-{0} below:", choices.Count);

                    string answer = Console.ReadLine();
                    int    validIndex;
                    inputValidation.ValidateUserQuestionEntry(answer, out validEntry, out validIndex);
                    if (validEntry)
                    {
                        var isCorrect = game.VerifyAnswer(validIndex, questionAsked);
                        if (isCorrect)
                        {
                            Console.WriteLine("Correct");
                            TotalPoints++;
                        }
                        else
                        {
                            Console.WriteLine("The correct answer is " + questionAsked.Choices[questionAsked.CorrectAnswerIndex]);
                        }
                    }
                }

                questionIndex++;
                QuestionsAsked++;
            }

            return(questionIndex);
        }
Esempio n. 3
0
 public int CorrectAnswerIndex(QuestionClass question)
 {
     return(question.CorrectAnswerIndex);
 }
Esempio n. 4
0
 public List <string> PrintChoices(QuestionClass question)
 {
     return(question.Choices);
 }
Esempio n. 5
0
 public string PrintQuestion(QuestionClass question)
 {
     return(question.Question);
 }