Exemple #1
0
        public Equation CreateEquation()
        {
            Equation eq = new Equation();
            IOperator theOp = GetRandomOperator();
            eq.Operation = theOp.Name;

            //get the set of numbers that followed the rules of the operator
            SetsOfNumbersLoader ss = new SetsOfNumbersLoader(theOp.OperationRules);
            var setOfNumbers = ss.GetSetOfNumbers();

            //pick random set and set that into the equation
            var randCombo = setOfNumbers[r.Next(0, setOfNumbers.Count())];
            eq.FirstNum = randCombo.X;
            eq.SecondNum = randCombo.Y;
            eq.Answer = theOp.TheOperation(eq.FirstNum, eq.SecondNum);

            return eq;
        }
Exemple #2
0
        public Equation CreateEquation()
        {
            Equation  eq    = new Equation();
            IOperator theOp = GetRandomOperator();

            eq.Operation = theOp.Name;

            //get the set of numbers that followed the rules of the operator
            SetsOfNumbersLoader ss = new SetsOfNumbersLoader(theOp.OperationRules);
            var setOfNumbers       = ss.GetSetOfNumbers();

            //pick random set and set that into the equation
            var randCombo = setOfNumbers[r.Next(0, setOfNumbers.Count())];

            eq.FirstNum  = randCombo.X;
            eq.SecondNum = randCombo.Y;
            eq.Answer    = theOp.TheOperation(eq.FirstNum, eq.SecondNum);

            return(eq);
        }