Exemple #1
0
        // Get all questions history and populate result in RightAnswers, WrongAnswers, ans ScorePercentage
        public void GetScore()
        {
            HistoryFile histfile = new HistoryFile();

            RightAnswers = 0;
            WrongAnswers = 0;

            foreach (AdditionQuestion question in histfile.GetAllItens())
            {
                if (question.Result)
                {
                    RightAnswers++;
                }
                else
                {
                    WrongAnswers++;
                }
            }

            ScorePercentage = (float)RightAnswers / (RightAnswers + WrongAnswers);
        }
Exemple #2
0
        public void VerifyResult()
        {
            // Verify if value was entered correctly
            if (UserResult == 0)
            {
                VerificationCode = VerificationCodeList.RESULT_ERROR_INVALID_ENTRY;
            }
            else
            {
                AdditionQuestion addQuestion = new AdditionQuestion(FirstNumber, SecondNumber, UserResult);

                if (addQuestion.Result)
                {
                    VerificationCode = VerificationCodeList.RESULT_OK;
                }
                else
                {
                    VerificationCode = VerificationCodeList.RESULT_WRONG;
                }

                HistoryFile histfile = new HistoryFile();
                histfile.AddItem(addQuestion);
            }
        }