private void RandomizeTrueOrFalseQuestions() { List <TrueOrFalseQuestion> tempQuestionList; tempQuestionList = _trueOrFalseQuestions; _trueOrFalseQuestions = new List <TrueOrFalseQuestion>(); while (tempQuestionList.Count > 0) { int randomIndex = _random.Next(0, tempQuestionList.Count); TrueOrFalseQuestion question = tempQuestionList[randomIndex]; _trueOrFalseQuestions.Add(question); tempQuestionList.Remove(tempQuestionList[randomIndex]); } }
public ComputerGeekGame() { try { if (File.Exists(_scoreBoardFileName)) { ReadScoresFromFile(); } else { FileStream stream = File.Create(_scoreBoardFileName); stream.Close(); } } catch (Exception e) { Console.WriteLine($"\nSomething went wrong when trying to load the leaderboard. The following error was generated: {e.Message} Please exit the game and try again."); } MultipleChoiceQuestion question1 = new MultipleChoiceQuestion("\n\nWho was the first computer programmer?", MultipleChoiceQuestion.Answers.B, "Charles Babbage", "Ada Lovelace", "Grace Hopper", "Alan turing"); MultipleChoiceQuestion question2 = new MultipleChoiceQuestion("\n\nWhich of the following was the first electrical computer: ", MultipleChoiceQuestion.Answers.A, "Collossus 1", "ENIAC", "Harvard Mark 1", "Pegassus I"); MultipleChoiceQuestion question3 = new MultipleChoiceQuestion("\n\nWho invented the first computer?", MultipleChoiceQuestion.Answers.C, "Ada Lovelace", "Aiken H. Howard", "Charless Babbage", "Tommy Flowers"); MultipleChoiceQuestion question4 = new MultipleChoiceQuestion("\n\nThe very first computer bug was a moth found in one of the following computers: ", MultipleChoiceQuestion.Answers.B, "Harvard Mark I", "Harvard Mark II", "Colossus Mark 1", "ENIAC"); MultipleChoiceQuestion question5 = new MultipleChoiceQuestion("\n\nWhich of the following was the first mechanical computer:", MultipleChoiceQuestion.Answers.D, "The Analytical Engine", "The Tabulating Machine", "The Mathematical Engine", "The Difference Engine"); TrueOrFalseQuestion question6 = new TrueOrFalseQuestion("\n\nTrue or False: The ENIAC was the first general purpose, programmable, electronic computer.", true); TrueOrFalseQuestion question7 = new TrueOrFalseQuestion("\n\nTrue or False: The Abacus is considered the very first computing device.", true); TrueOrFalseQuestion question8 = new TrueOrFalseQuestion("\n\nTrue or False: The Difference Engine was never actually created.", false); TrueOrFalseQuestion question9 = new TrueOrFalseQuestion("\n\nTrue or False: Harvard Mark I was one of the first computers which were powered by vacuum tubes.", false); TrueOrFalseQuestion question10 = new TrueOrFalseQuestion("\n\nTrue or False: The ENIAC is estimated to have done more arithmetic calculations than the entire human race up to that point.", true); _multipleChoiceQuestions = new List <MultipleChoiceQuestion>() { question1, question2, question3, question4, question5 }; _trueOrFalseQuestions = new List <TrueOrFalseQuestion>() { question6, question7, question8, question9, question10 }; }