Example #1
0
 public void makeStats(Questioner qr)
 {
     stats = new Dictionary<Question, int>(qr.questions.Count);
     foreach (Question q in qr.questions)
     {
         stats[q] = 0;
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            if (!File.Exists(QuestionFile))
            {
                Console.WriteLine("No questions were loaded, as " + QuestionFile + " does not exist.");
                goto Exit;
            }
            var q = new Questioner(QuestionFile);

            while (true)
            {
                if (!q.nextQuestion())
                {
                    Console.WriteLine("We've run out of questions to ask! You're ready for the test :D!");
                    goto Exit;
                }
                Console.WriteLine(q.getQuestion());
                int numTimesTried = 0;
                while (true)
                {
                    ++numTimesTried;
                    string ans = Console.ReadLine();
                    if (ans.ToLower() == "q" || ans.ToLower() == "quit" || ans.ToLower() == "exit")
                    {
                        goto Exit;
                    }
                    if (q.isValidAnswerCaseInsensitive(ans))
                    {
                        int newscore = q.Award();
                        Console.WriteLine("{0}", getEncouragingStatement());
                        Console.WriteLine("This question is now at score {0}\n", newscore);
                        if (newscore >= knownLevel)
                        {
                            q.removeQuestion();
                            Console.WriteLine("You've gotten a high enough score that this question has been removed!\n\n");
                        }
                        break;
                    }
                    else
                    {
                        Console.Write("That answer was incorrect. ");
                        if (numTimesTried >= numTriesPerQuestion)
                        {
                            int newscore = q.Punish();
                            Console.WriteLine("This question is now at score {0}\n", newscore);
                            Console.WriteLine("Possible answers were:");
                            foreach (var answer in q.getValidAnswers())
                            {
                                Console.WriteLine("\t{0}", answer);
                            }
                            break;
                        }
                        else
                        {
                            int triesRemaining = numTriesPerQuestion - numTimesTried;
                            if (triesRemaining == 1)
                            {
                                Console.WriteLine("1 attempt left.");
                            }
                            else
                            {
                                Console.WriteLine("{0} attempts left.", triesRemaining);
                            }
                        }
                    }
                }
            }
            Exit:
            Console.Write("\nEnding Execution.\n");
        }
Example #3
0
 public QuestionSelector(Questioner qr)
 {
     makeStats(qr);
 }