コード例 #1
0
 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" });
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: gcspino/LearningGame
        public bool AttemptProblem(Problem problem, int answer)
        {
            bool correct = problem.IsSolution(answer);
            if(correct)
            {
                Score++;
            }
            else
            {
                // nothingl
            }

            return correct;
        }
コード例 #3
0
        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);
        }