public override void UseHelpOption(Question question, Dictionary <string, int> answerChoices) { if (IsUsed == false) { IsUsed = true; int answer = rnd.Next(question.PossibleAnswers.Count()); int fifty = question.PossibleAnswers.Count() / 2; int removed = 0; for (int i = 0; i < question.PossibleAnswers.Length; i++) { if (removed < fifty && question.CheckIsCorrectAnswer(i)) { question.PossibleAnswers[i] = ""; removed++; } else { string answerLetter = answerChoices .FirstOrDefault(x => x.Value == i) .Key; Console.WriteLine($"{answerLetter}) {question.PossibleAnswers[i]}"); } } } }
public override void Start() { try { GenerateQuestion15(); int i = 0; while (i < questions15.Length) { Question question = questions15[i]; PrintQuestion(i, question); PrintHelpOptions(); Console.WriteLine("Answer = "); string answer = Console.ReadLine().ToUpper(); if (answerChoices.ContainsKey(answer)) { question.SelectedAnswer = answerChoices[answer]; if (!question.CheckIsCorrectAnswer(answerChoices[answer])) { break; } i++; Console.Clear(); } else { switch (answer) { case "HAA": hAA.UseHelpOption(question, answerChoices); break; case "HCF": hCF.UseHelpOption(question, answerChoices); break; case "HFF": hFF.UseHelpOption(question, answerChoices); break; default: Console.Clear(); break; } } } if (i == questions15.Length) { Console.WriteLine("--------------------------------------------------------"); Console.WriteLine("Congratulations You are a Millionaire"); } else { int correctAnswer = questions15[i].GetCorrectAnswer(); string correctAnswerLetter = answerChoices .FirstOrDefault(x => x.Value == correctAnswer) .Key; Console.WriteLine("--------------------------------------------------------"); Console.WriteLine($"GAME OVER. CorrectAnswer = {correctAnswerLetter}"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }