示例#1
0
 internal Quiz()
 {
     Name        = GameHelpers.GetAnswer("Enter name for this Quiz: ");
     Questions   = new List <Question>();
     UserChoices = new List <Answer>();
     Correct     = 0.00;
 }
示例#2
0
        private static void PlayAgain(Game game)
        {
            string choice       = GameHelpers.GetAnswer("Do you want to play again ?", game);
            Option pickedOption = game.Options.Find(option => option.ID.Equals(int.Parse(choice)));

            game.IsRunning = pickedOption.Name.Equals("Yes");
            Console.Clear();
        }
示例#3
0
 public static void DisplayEnding()
 {
     DisplayAlternatingSymbols('*');
     TransitionEffectHalfConsole();
     GameHelpers.PrintSlow(". . . . . . . . ", 150);
     GameHelpers.PrintSlow("Good bye!");
     Thread.Sleep(1000);
 }
示例#4
0
 internal void Play()
 {
     SetUpQuestions();
     StartQuiz();
     GameHelpers.PrintSlow(GradeQuiz());
     GameHelpers.PrintSlow("\n\nGame is about to end");
     GameHelpers.PrintSlow(" . . . . . . . .", 100);
 }
示例#5
0
 protected virtual void MakePossibleAnswers(int numberOfPossibleAnswers)
 {
     Console.Clear();
     GameHelpers.PrintSlow(string.Format("Enter {0} possible answers\n", numberOfPossibleAnswers));
     for (int i = 0; i < numberOfPossibleAnswers; i++)
     {
         Console.Write("{0}: ", i + 1);
         Answers.Add(new Answer(i + 1, Console.ReadLine()));
     }
 }
示例#6
0
 private void StartQuiz()
 {
     foreach (Question question in Questions)
     {
         string choice = GameHelpers.GetAnswer("Question: ", question);
         UserChoices.Add(question.Answers.Find(answer => answer.ID.Equals(int.Parse(choice))));
         //UNDER CONSTRUCTION
         //IList<char> choices = ChooseAnswer(question;
         //var query = choices.SelectMany(
         //    choice => question.Answers.Where(
         //        answer => answer.ID.Equals(int.Parse(choice.ToString()))));
     }
 }
示例#7
0
        protected virtual void SetCorrectAnswer()
        {
            int    answer        = int.Parse(GameHelpers.GetAnswer(string.Format("Question: {0}\n\nChoose which of the following answers are correct: ", Name), Answers));
            Answer correctAnswer = (Answers.Find(individualAnswer => individualAnswer.ID.Equals(answer)));

            correctAnswer.IsCorrectAnswer = true;
            ////Testing for correct answer being chosen
            //foreach (Answer singleAnswer in Answers)
            //{
            //    Console.WriteLine("Correct? => {0}", singleAnswer.IsCorrectAnswer);
            //}
            //Console.Write("To continue, press ENTER");
            //Console.Read();
        }
示例#8
0
        public static void TransitionEffect(string prompt)
        {
            for (int m = 0; m < Console.WindowWidth / 4; m++)
            {
                Console.Write(" ");
            }
            GameHelpers.PrintSlow(prompt);
            Console.WriteLine();
            for (int m = 0; m < Console.WindowWidth / 5; m++)
            {
                Console.Write(" ");
            }
            GameHelpers.PrintSlow("If you did not want to begin, sorry, you're stuck unless you close the console :)");
            Console.ReadLine();
            Thread.Sleep(250);

            TransitionEffectHalfConsole();
        }
        public static string GetAnswer(string prompt, Game game)
        {
            string answer;

            do
            {
                GameHelpers.PrintQuestionOut(prompt, game.Options);
                Console.Write("\nChoice: ");
                answer = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(answer))
                {
                    PrintSlow("You did not enter what was expected: \nRe-prompting");
                    PrintSlow(" . . . . .", 75);
                    Console.Clear();
                }
            } while (string.IsNullOrWhiteSpace(answer) || !IsValidSelection(answer, game.Options));
            return(answer);
        }
示例#10
0
        // do not use, must refactor for use with CheckBoxes
        //public List<char> ChooseAnswer(Question question)
        //{
        //    List<char> choices;
        //    Console.Write("Enter your choice or choice(s) [if more than one just group it i.e. 123]: ");
        //    do
        //    {
        //        string input = Console.ReadLine();
        //        choices = input.ToList();
        //    } while (choices.Contains(',') || choices.Contains(' ') || !(choices.TrueForAll(key => char.IsDigit(key) ? !(int.Parse(key.ToString()) < 1 || int.Parse(key.ToString()) > question.Answers.Count) : false )));

        //    return choices;
        //}

        private string GradeQuiz()
        {
            Console.Clear();
            IList <Answer> correct = UserChoices.FindAll(answer => answer.IsCorrectAnswer);

            Correct = QuizGrader((double)correct.Count, (double)UserChoices.Count);

            GameHelpers.PrintSlow("Grading quiz");

            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(250);
                Console.Write(" .");
            }
            GameHelpers.PrintSlow(" Done!\nNow for the moment of truth, see results below\n");

            string result = string.Format("Result: {0} out of {1} correct: {2:P}", correct.Count, UserChoices.Count, Correct);

            return(result);
        }
示例#11
0
 protected string MakeQuestionName()
 {
     Console.Clear();
     return(GameHelpers.GetAnswer("Please enter the question: "));
 }
示例#12
0
 private Question DetermineQuestionType()
 {
     return(MakeQuestionType(GameHelpers.GetAnswer("What kind of question do you want this question to be:", QuestionTypesStringVersion)));
 }
示例#13
0
 private int DetermineQuestionAmount()
 {
     Console.Clear();
     return(int.Parse(GameHelpers.GetQuestionAmount()));
 }