Ejemplo n.º 1
0
        // THE REQUESTOR OF THE ENGINE USED DETERMINES THE ALGORITHM
        // USED STRATEGY DESIGN PATTERN

        public IconstantEngine GetconstantEngine()
        {
            IconstantEngine constantEngine = null;

            constantEngine = new DotNetEngine();
            return(constantEngine);
        }
Ejemplo n.º 2
0
        // WEBAPI2 HAS METHOD SIGNATURE ROUTING
        public CalculatorResult Get()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.Triangle2DEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate();
            return(new CalculatorResult(rc.PI, rc.CalculationTime));
        }
Ejemplo n.º 3
0
        public void TestMethod_ArcTangent()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.ArcTangentEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate();
            Assert.AreEqual(rc.PI, 3.14, 0.05, "INVALID ARCTANGENT CALCULATION");
        }
Ejemplo n.º 4
0
        public void TestMethod_EgyptianPyramid()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.EgyptianPyramidEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate();
            Assert.AreEqual(rc.PI, 3.14, 0.05, "INVALID EGYPT CALCULATION");
        }
Ejemplo n.º 5
0
        public void TestMethod_MonteCarlo3D_100()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.MonteCarlo3DEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate(100);
            Assert.AreEqual(rc.PI, 3.141, 0.005, "INVALID MONTECARLO 3D CALCULATION");
        }
Ejemplo n.º 6
0
        public void TestMethod_Nilakantha()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.NilakanthaEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate(10000);
            Assert.AreEqual(rc.PI, 3.14, 0.05, "INVALID NILAKANTHA CALCULATION");
        }
Ejemplo n.º 7
0
        public void TestMethod_GregoryLeibniz_HundredMillionCalc()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.GregoryLeibnizEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate(1000000 * 10);
            Assert.AreEqual(rc.PI, 3.14, 0.005, "INVALID GREGORY-LEIBNIZ CALCULATION");
        }
Ejemplo n.º 8
0
        public CalculatorResult Calculate()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine();
            CalculatorResult rc = null;

            rc = engine.Calculate();
            return(new CalculatorResult(rc.PI, rc.CalculationTime));
        }
Ejemplo n.º 9
0
        public void TestMethod_Pyramid2DEngine()
        {
            ConstantModel   model  = new ConstantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine(PI_ENGINE_TYPE.Triangle2DEngine);
            //engine = model.GetconstantEngine(PI_ENGINE_TYPE.GregoryLeibnizEngine);
            CalculatorResult rc = null;

            rc = engine.Calculate(1000);
            Assert.AreEqual(rc.PI, 3.14, 0.10, "INVALID PYRAMID2D CALCULATION");
        }
Ejemplo n.º 10
0
    protected void btnCalculate_Click(object sender, EventArgs e)
    {
        constantModel   model  = new constantModel();
        IconstantEngine engine = null;

        engine = model.GetconstantEngine();
        CalculatorResultModel rc = null;

        rc             = engine.Calculate();
        txtResult.Text = "Value for PI " + rc.PI + "\n" +
                         "Calculation Time " + rc.CalculationTime.ToString() + " millisecond(s)" + "\n" +
                         "Moon Volume " + rc.MoonVolume.ToString();
    }
Ejemplo n.º 11
0
        public IconstantEngine GetconstantEngine(PI_ENGINE_TYPE enginetype)
        {
            IconstantEngine constantEngine = null;

            switch (enginetype)
            {
            case PI_ENGINE_TYPE.NilakanthaEngine:
                constantEngine = new NilakanthaEngine();
                break;

            case PI_ENGINE_TYPE.ArcTangentEngine:
                constantEngine = new ArcTangentEngine();
                break;

            case PI_ENGINE_TYPE.DotNetEngine:
                constantEngine = new DotNetEngine();
                break;

            case PI_ENGINE_TYPE.EgyptianPyramidEngine:
                constantEngine = new EgyptianPyramidEngine();
                break;

            case PI_ENGINE_TYPE.GregoryLeibnizEngine:
                constantEngine = new GregoryLeibnizEngine();
                break;

            case PI_ENGINE_TYPE.MonteCarlo2DEngine:
                constantEngine = new MonteCarloEngine();
                break;

            case PI_ENGINE_TYPE.MonteCarlo3DEngine:
                constantEngine = new MonteCarloCubicEngine();
                break;

            case PI_ENGINE_TYPE.Triangle2DEngine:
                constantEngine = new TriangleEngine2D();
                break;

            case PI_ENGINE_TYPE.Triangle3DEngine:
                constantEngine = new TriangleEngine3D();
                break;

            default:
                constantEngine = new DotNetEngine();
                break;
            }
            return(constantEngine);
        }
Ejemplo n.º 12
0
        // GET: Calculator
        public ActionResult Index(string btnCalculate)

        {
            if (btnCalculate == "Calculate")
            {
                ConstantModel   model  = new ConstantModel();
                IconstantEngine engine = null;
                engine = model.GetconstantEngine();
                CalculatorResult rc = null;
                rc = engine.Calculate();
                return(View(new CalculatorResult(rc.PI, rc.CalculationTime)));
            }
            else
            {
                return(View(new CalculatorResult()));
            }
        }
Ejemplo n.º 13
0
        public CalculatorResultModel Calculate()
        {
            // FIELD VALIDATIONS
            // OR USE GENERIC HTTP ERROR VALUE FUNCTION
            // NLOG TRANSACTIONS AND ERRORS
            // VALIDATION SHOULD OCCUR AT EACH LEVEL OF COMMUNICATION
            // HTML VALIDATION BEFORE SEND
            // WEBAPI2 VALIDATION


            constantModel   model  = new constantModel();
            IconstantEngine engine = null;

            engine = model.GetconstantEngine();
            CalculatorResultModel rc = null;

            rc = engine.Calculate();
            return(new CalculatorResultModel(rc.PI, rc.CalculationTime));
        }