Esempio n. 1
0
        public static void Main()
        {
            //instantiate calculator
            Calculator calculator = new Calculator();

            //instantiate add and minus
            List <IOperator> simpleOperators = new List <IOperator>();

            simpleOperators.Add(new AddOperator());
            simpleOperators.Add(new MinusOperator());

            //instantiate product and division (they have proprity)
            List <IOperator> prioritaryOperators = new List <IOperator>();

            prioritaryOperators.Add(new ProductOperator());
            prioritaryOperators.Add(new DivisionOperator());

            //add the operations to the calculator
            calculator.Operators.Add(prioritaryOperators);
            calculator.Operators.Add(simpleOperators);

            //predefine the operations
            string[] operations = { "1+2,3", "2 x 3,6", "6-1-3,8", "6,6/3", "6/0", "not an operation", "a+1", "12", "" };

            //Run the operations
            CalculatorTrainer.Run(calculator, operations);
            System.Console.ReadKey();
        }
Esempio n. 2
0
        public static void Main()
        {
            ConnecteurFichier          operationsListe = new ConnecteurFichier();
            List <IOperationInterface> interfaces      = new List <IOperationInterface>();
            OperationInterfaceMult     mult            = new OperationInterfaceMult();
            OperationInterfaceDiv      div             = new OperationInterfaceDiv();
            OperationInterfaceSum      sum             = new OperationInterfaceSum();
            OperationInterfaceSub      sub             = new OperationInterfaceSub();

            interfaces.Add(mult);
            interfaces.Add(div);
            interfaces.Add(sum);
            interfaces.Add(sub);
            var calculatorTrainer = new CalculatorTrainer(operationsListe);

            calculatorTrainer.Run(interfaces);
        }
Esempio n. 3
0
        public void CalculateASum()
        {
            //var operations = new List<IOperations> { new Sum(), new Sub(), new Div(), new Multi() };
            var calculatorTrainer = new CalculatorTrainer();

            calculatorTrainer.Run();

            // Addition

            /* var result = calculator.Calculate("1+2,3");
             * Check.That(result).IsEqualTo(3.3m);
             *
             * result = calculator.Calculate("1+4+6");
             * Check.That(result).IsEqualTo(11m);
             *
             * result = calculator.Calculate("9");
             * Check.That(result).IsEqualTo(9m);
             *
             * result = calculator.Calculate("213+ezzrz");
             * Check.That(result).IsEqualTo(0m);
             *
             *
             *
             * //Soustraction
             * result = calculator.Calculate("4-1");
             * Check.That(result).IsEqualTo(3m);
             *
             * result = calculator.Calculate("6-3");
             * Check.That(result).IsEqualTo(3m);
             *
             * result = calculator.Calculate("12-3");
             * Check.That(result).IsEqualTo(9m);
             *
             * result = calculator.Calculate("9");
             * Check.That(result).IsEqualTo(9m);
             *
             * result = calculator.Calculate("213-ezzrz");
             * Check.That(result).IsEqualTo(0m);
             *
             *
             *
             *
             * //Division
             * result = calculator.Calculate("4/1");
             * Check.That(result).IsEqualTo(4m);
             *
             * result = calculator.Calculate("6/3");
             * Check.That(result).IsEqualTo(2m);
             *
             * result = calculator.Calculate("12/3");
             * Check.That(result).IsEqualTo(4m);
             *
             * result = calculator.Calculate("9");
             * Check.That(result).IsEqualTo(9m);
             *
             * result = calculator.Calculate("213/ezzrz");
             * Check.That(result).IsEqualTo(0m);
             *
             *
             *
             *
             * //Division
             * result = calculator.Calculate("4*1");
             * Check.That(result).IsEqualTo(4m);
             *
             * result = calculator.Calculate("6*3");
             * Check.That(result).IsEqualTo(18m);
             *
             * result = calculator.Calculate("12*3");
             * Check.That(result).IsEqualTo(36m);
             *
             * result = calculator.Calculate("9");
             * Check.That(result).IsEqualTo(9m);
             *
             * result = calculator.Calculate("213*ezzrz");
             * Check.That(result).IsEqualTo(0m);
             *
             *
             *
             *
             * // Autre
             * result = calculator.Calculate("zzrz");
             * Check.That(result).IsEqualTo(0m);*/
        }
Esempio n. 4
0
        public void CalculatorTrainerTest()
        {
            CalculatorTrainer ct = new CalculatorTrainer();

            ct.Run();
        }
        public void CalculatorTrainer()
        {
            var calcTrainer = new CalculatorTrainer();

            calcTrainer.Run();
        }
Esempio n. 6
0
        public static void Main()
        {
            var calculatorTrainer = new CalculatorTrainer(new OperationGenerator());

            calculatorTrainer.Run();
        }
Esempio n. 7
0
        public static void Main()
        {
            var calculatorTrainer = new CalculatorTrainer();

            calculatorTrainer.Run(new GeneratedOperations(), new Calculator());
        }
Esempio n. 8
0
        public static void Main()
        {
            var calculatorTrainer = new CalculatorTrainer();

            calculatorTrainer.Run();
        }