예제 #1
0
        public void SetAnswerForCurrentQuestionAndEndSessionIfRequired(int ans)
        {
            QuestionProvider.Question q = _questions[_currentQuestion];

            if (ans == q.sol)
            {
                _passedQuestions.Add(q);
            }
            else
            {
                _failedQuestions.Add(q);
            }

            if (!IsNextQuestionAvailable())
            {
                StopSession();
            }
        }
        private void StartSession()
        {
            controller.StartSession();

            while (controller.IsNextQuestionAvailable())
            {
                QuestionProvider.Question q = controller.GetNextQuestion();
                ConsoleWriter.Print($"{q.a} {q.operatorStr} {q.b}");
                int ans = ConsoleReader.GetUserInputInt("");
                if (!controller.IsAnswerForCurrentQuestionRight(ans))
                {
                    ConsoleWriter.PrintInColor("Naah. That was not right!", ConsoleColor.Yellow);
                }
                controller.SetAnswerForCurrentQuestionAndEndSessionIfRequired(ans);
            }

            ShowResults();
        }