Esempio n. 1
0
        static void Main(string[] args)
        {
            StartNumber startNumber = new StartNumber(5);
            IFormula    formula     = new AddFormula(new MulFormula(new SubFormula(new DivFormula(new AddFormula(new MulFormula(startNumber, 2), 100), 12), 3), 4), 7);

            Console.WriteLine("The formula is: " + formula.GetFormula());
            Console.WriteLine("The result of it is: " + formula.GetResult());

            Console.WriteLine("First number changed to 30.....");
            startNumber.modifyNumber(30);

            IFormula formulaAfterChange = new AddFormula(new MulFormula(new SubFormula(new DivFormula(new AddFormula(new MulFormula(startNumber, 2), 100), 12), 3), 4), 7);

            Console.WriteLine("The formula is: " + formulaAfterChange.GetFormula());
            Console.WriteLine("The result of it is: " + formulaAfterChange.GetResult());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            IFormula form = new StartNumber(5);


            IFormula multToNumber = new Mult(form, 2);

            Console.WriteLine(multToNumber.GetFormula() + " = " + multToNumber.GetResult());
            IFormula addToNumber = new Add(multToNumber, 100);

            Console.WriteLine(addToNumber.GetFormula() + " = " + addToNumber.GetResult());
            IFormula divideToNumber = new Divide(addToNumber, 12);

            Console.WriteLine(divideToNumber.GetFormula() + " = " + divideToNumber.GetResult());
            IFormula subToNumber = new Sub(divideToNumber, 3);

            Console.WriteLine(subToNumber.GetFormula() + " = " + subToNumber.GetResult());
            IFormula mult2ToNumber = new Mult(subToNumber, 4);

            Console.WriteLine(mult2ToNumber.GetFormula() + " = " + mult2ToNumber.GetResult());
            IFormula add2ToNumber = new Add(mult2ToNumber, 7);

            Console.WriteLine(add2ToNumber.GetFormula() + " = " + add2ToNumber.GetResult());
        }