示例#1
0
        public MathEquation GenerateEquation()
        {
            var oneSide   = _randomGenerator.Int(0, 10);
            var otherSide = _randomGenerator.Int(0, 10);
            var @operator = GetOperator(_randomGenerator.Double());

            var actualResult    = Math.Round(GetResult(oneSide, otherSide, @operator), 1);
            var useActualResult = _randomGenerator.Bool();

            double shownResult;

            if (useActualResult)
            {
                shownResult = actualResult;
            }
            else
            {
                shownResult = Math.Round(GenerateProbableResult(@operator, actualResult), 0);
            }

            var equationString = GetEquationString(oneSide, otherSide, shownResult, @operator);

            return(new MathEquation(equationString, new[] { actualResult }, shownResult, ANSWER_TOLERANCE));
        }