//Instance Method public void Start(/* ConsoleUI this = referance of object */) { //1. Get one question and display it in the user BusinessLogicLayer bll = new BusinessLogicLayer(); // bll is a referance variable that holds referance of object // the object is created in heap //bll is created on stack while (true) { Question question = bll.GetNextQuestion(); // get one question at a time if (question == null) { break; } else { System.Console.Clear(); System.Console.ForegroundColor = System.ConsoleColor.Blue; System.Console.WriteLine(question.Statement); System.Console.WriteLine($"1: {question.Option1}"); System.Console.WriteLine($"2: {question.Option2}"); System.Console.WriteLine($"3: {question.Option3}"); System.Console.WriteLine($"1: {question.Option1}"); System.Console.WriteLine($"Marks: {question.Marks}"); System.Console.ForegroundColor = System.ConsoleColor.Yellow; System.Console.Write("Select an Option : "); int option = System.Convert.ToInt32(System.Console.ReadLine()); bll.CalculateMarks(option); } } // while ends if (bll.Results.Count > 0) { for (int i = 0; i < bll.Results.Count; i++) { Console.WriteLine(bll.Results[i].Question.Statement); string CorrectOptionText = " "; switch (bll.Results[i].Question.CorrectAnswer) { case 1: CorrectOptionText = bll.Results[i].Question.Option1; break; case 2: CorrectOptionText = bll.Results[i].Question.Option2; break; case 3: CorrectOptionText = bll.Results[i].Question.Option3; break; case 4: CorrectOptionText = bll.Results[i].Question.Option4; break; } string WrongOptionText = " "; switch (bll.Results[i].Wronganswwer) { case 1: WrongOptionText = bll.Results[i].Question.Option1; break; case 2: WrongOptionText = bll.Results[i].Question.Option2; break; case 3: WrongOptionText = bll.Results[i].Question.Option3; break; case 4: WrongOptionText = bll.Results[i].Question.Option4; break; } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"User Option is : {WrongOptionText}"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"Correct Answer is : {CorrectOptionText}"); } Console.Clear(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"You Obtained {bll.Usermarks} out of {bll.TotalMarks}"); } }