Esempio n. 1
0
    public void Show()
    {
        Console.WriteLine("Please wait while we load the questions from the server....");

        TestLogic testLogic = new TestLogic(); // long lived object

        // 1. Object is created with instance data members in it
        // 2. constructor is called with the ref. of the object
        // 3. reference of the object is stored in testLogic reference variable

        while (true)
        {
            Question question = testLogic.GetNextQuestion();
            // question is a reference variable that receives reference of the Question object

            if (question != null)
            {
                Console.Clear();
                DisplayQuestion(question);
                int option = this.GetOptionFromUser();
                testLogic.CheckAnswer(option);
            }
            else
            {
                break;
            }
        }

        Console.Clear();
        Console.WriteLine($"You obtained {testLogic.UserMarks} out of {testLogic.TotalMarks}");
        Console.ReadLine();
    }