public MainWindowViewModel()
 {
     game = new BasicGame(0, 10, new List<string>() { "+", "-" }, 15);
     CurrentProblem = game.Problems[0];
     NotifyPropertyChanged(string.Empty);
     resources = new ResponseResources(string.Concat(AppDomain.CurrentDomain.BaseDirectory, "Images\\"), new List<string> { "correct", "wrong" });
 }
Exemple #2
0
        public bool AttemptProblem(Problem problem, int answer)
        {
            bool correct = problem.IsSolution(answer);
            if(correct)
            {
                Score++;
            }
            else
            {
                // nothingl
            }

            return correct;
        }
        public void AnswerCurrentProblem(int answer)
        {
            Feedback = "";
            if (game.AttemptProblem(CurrentProblem, answer))
            {
                // correct
                SetFeedback("correct");
                problemIndex++;
                attempts = 0;
            }
            else
            {
                // incorrect
                attempts++;
                if (attempts > 1)
                {
                    SetFeedback("wrong");
                    Feedback = CurrentProblem.AnswerText();
                    problemIndex++;
                    attempts = 0;
                }
                else
                {
                    Feedback = "Try again!";
                }
            }

            if (problemIndex >= game.Problems.Count())
            {
                CurrentProblem = null;
                Feedback = string.Concat("Complete: ", Score, "/", game.Problems.Count());
            }
            else
            {
                CurrentProblem = game.Problems[problemIndex];
            }
            NotifyPropertyChanged(string.Empty);
        }