internal Quiz() { Name = GameHelpers.GetAnswer("Enter name for this Quiz: "); Questions = new List <Question>(); UserChoices = new List <Answer>(); Correct = 0.00; }
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(); }
public static void DisplayEnding() { DisplayAlternatingSymbols('*'); TransitionEffectHalfConsole(); GameHelpers.PrintSlow(". . . . . . . . ", 150); GameHelpers.PrintSlow("Good bye!"); Thread.Sleep(1000); }
internal void Play() { SetUpQuestions(); StartQuiz(); GameHelpers.PrintSlow(GradeQuiz()); GameHelpers.PrintSlow("\n\nGame is about to end"); GameHelpers.PrintSlow(" . . . . . . . .", 100); }
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())); } }
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())))); } }
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(); }
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); }
// 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); }
protected string MakeQuestionName() { Console.Clear(); return(GameHelpers.GetAnswer("Please enter the question: ")); }
private Question DetermineQuestionType() { return(MakeQuestionType(GameHelpers.GetAnswer("What kind of question do you want this question to be:", QuestionTypesStringVersion))); }
private int DetermineQuestionAmount() { Console.Clear(); return(int.Parse(GameHelpers.GetQuestionAmount())); }