Exemple #1
0
        // Constructor
        public CalculatorCommand(Calculator calculator,
            char @operator, int operand)
        {
            this.calculator = calculator;

            this.@operator = @operator;

            this.operand = operand;
        }
        private static void Main()
        {
            Console.WriteLine($"X is 20 and Y is 10");
            var calculator = new Calculator(20, 10);

            var cmdAdd = new AddCommand(calculator);
            Console.WriteLine($"Sum is {cmdAdd.Execute()}");

            var cmdSub = new SubstractCommand(calculator);
            Console.WriteLine($"Substract is {cmdSub.Execute()}");

            var cmdMul = new MultiplyCommand(calculator);
            Console.WriteLine($"Multiply is {cmdMul.Execute()}");
        }
Exemple #3
0
 public User(Calculator calculator)
 {
     Calculator = calculator;
 }
Exemple #4
0
 public CalculatorCommand(Calculator calculator, Operation operation, int operand)
 {
     _calculator = calculator;
     _operation  = operation;
     _operand    = operand;
 }
Exemple #5
0
 public Add(Calculator calculator)
 {
     _calculator = calculator;
 }