void PreviousButtonClicked(object sender, EventArgs e) { if (op1.Checked) { tl.CalculateUserMarks(1); } else if (op2.Checked) { tl.CalculateUserMarks(2); } else if (op3.Checked) { tl.CalculateUserMarks(3); } else if (op4.Checked) { tl.CalculateUserMarks(4); } Question question = tl.GetPreviousQuestion(); if (question != null) { DisplayQuestion(question); } }
public void StartTest() { TestLogic tl = new TestLogic(); while (true) { Question question = tl.GetNextQuestion(); if (question == null) { break; // test is over } // Display one question at a time Console.Clear(); Console.WriteLine(question.Statement); Console.WriteLine("1: " + question.Op1); Console.WriteLine("2: " + question.Op2); Console.WriteLine("3: " + question.Op3); Console.WriteLine("4: " + question.Op4); // take the user's choice Console.Write("Select an option: "); int choice = Convert.ToInt32(Console.ReadLine()); tl.CalculateUserMarks(choice); } // finally display usermarks out of total marks Console.Clear(); Console.WriteLine("You obtained {0} out of {1}", tl.GetUserMarks(), tl.GetTotalMarks()); }