Exemple #1
0
        private IEnumerable <IEquation> MapDaoToDto(IEnumerable <Equation> equationDal)
        {
            var result = new List <IEquation>();

            foreach (var item in equationDal)
            {
                if (item.Type == 1)
                {
                    var eqDto = new SeparableVariables();
                    eqDto.Equation      = item.Eq;
                    eqDto.EquationLatex = item.Latex;
                    eqDto.Solution      = item.Solution;
                    eqDto.SolutionLatex = item.SolutionLatex;
                    result.Add(eqDto);
                }
                else if (item.Type == 2)
                {
                    var eqDto = new Homogeneous();
                    eqDto.Equation      = item.Eq;
                    eqDto.EquationLatex = item.Latex;
                    eqDto.Solution      = item.Solution;
                    eqDto.SolutionLatex = item.SolutionLatex;
                    result.Add(eqDto);
                }
                else
                {
                    throw new NotImplementedException("No mapper for this equation type");
                }
            }
            return(result);
        }
Exemple #2
0
 private IEquation MapJsonToDto(PyEquationJson equationJson, int equationType)
 {
     if (equationType == 1)
     {
         var sv = new SeparableVariables();
         sv.Equation      = equationJson.LeftSide + " = " + equationJson.RightSide;
         sv.EquationLatex = equationJson.EquationLatex;
         sv.Solution      = equationJson.Solution;
         sv.SolutionLatex = equationJson.SolutionLatex;
         return(sv);
     }
     else if (equationType == 2)
     {
         var hg = new Homogeneous();
         hg.Equation      = equationJson.LeftSide + " = " + equationJson.RightSide;
         hg.EquationLatex = equationJson.EquationLatex;
         hg.Solution      = equationJson.Solution;
         hg.SolutionLatex = equationJson.SolutionLatex;
         return(hg);
     }
     else
     {
         throw new NotImplementedException($"equationType {equationType} is not supported for mapping");
     }
 }
Exemple #3
0
        private async Task <IEquation> Generate(Homogeneous hg)
        {
            var ran             = new Random();
            var generator       = new RandomFunctionGenerator(new HomogeneousTreeStrategy());
            var equationHandler = new SolverHandler();

            hg.Equation = "(" + generator.Generate("y/x", (1 + 2 * ran.Next(1, 2))) + ")" + "/" + "(" + generator.Generate("y/x", (1 + 2 * ran.Next(1, 2))) + ")" + "=" + "dydx";
            hg          = (Homogeneous)await equationHandler.SolveAndScramble(hg);

            return(hg);
        }