Example #1
0
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
            type = (SubGameTypes)random.Next((int)SubGameTypes.Length);

            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                max_operand = 8;
                break;

            case GameDifficulty.Medium:
                max_operand = 10;
                break;

            case GameDifficulty.Master:
                max_operand = 15;
                break;
            }

            number_a = 5 + random.Next(max_operand);
            number_b = 3 + random.Next(max_operand);

            switch (type)
            {
            case SubGameTypes.Addition:
                op1 = number_a + number_b;
                break;

            case SubGameTypes.Subtraction:
                if (number_a < number_b)
                {
                    int tmp = number_a;

                    number_a = number_b;
                    number_b = tmp;
                }
                op1 = number_a - number_b;
                break;

            default:
                throw new InvalidOperationException();
            }

            op2                    = number_a * number_b;
            Answer.Correct         = String.Format("{0} | {1}", number_a, number_b);
            Answer.CheckExpression = "[-0-9]+";
            Answer.CorrectShow     = String.Format(ServiceLocator.Instance.GetService <ITranslations> ().GetString("{0} and {1}"), number_a, number_b);
        }
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
            type = (SubGameTypes) random.Next ((int) SubGameTypes.Length);

            switch (CurrentDifficulty) {
            case GameDifficulty.Easy:
                max_operand = 8;
                break;
            case GameDifficulty.Medium:
                max_operand = 10;
                break;
            case GameDifficulty.Master:
                max_operand = 15;
                break;
            }

            number_a = 5 + random.Next (max_operand);
            number_b = 3 + random.Next (max_operand);

            switch (type) {
            case SubGameTypes.Addition:
                op1 = number_a + number_b;
                break;
            case SubGameTypes.Subtraction:
                if (number_a < number_b) {
                    int tmp = number_a;

                    number_a = number_b;
                    number_b = tmp;
                }
                op1 = number_a - number_b;
                break;
            default:
                throw new InvalidOperationException ();
            }

            op2 = number_a * number_b;
            Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
            Answer.CheckExpression = "[-0-9]+";
            Answer.CorrectShow = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), number_a, number_b);
        }