예제 #1
0
        public decimal Calculate(string text)
        {
            var query = _queryParser.Parse(text);

            var result = 0m;

            switch (query.Operation)
            {
            case "x":
                result = _multiplier.Multiply(query.FirstNumber, query.SecondNumber);
                break;

            case "+":
                result = _adder.Add(query.FirstNumber, query.SecondNumber);
                break;

            case "-":
                result = _subtractor.Subtract(query.FirstNumber, query.SecondNumber);
                break;

            case "/":
                result = _divider.Divide(query.FirstNumber, query.SecondNumber);
                break;
            }

            return(result);
        }
예제 #2
0
        public void DoMath()
        {
            switch (selectOperator)
            {
            case "+":
                Console.WriteLine(adder.Add());
                break;

            case "-":
                Console.WriteLine(subtractor.Subtract( ));
                break;

            case "*":
                Console.WriteLine(multiplier.Multiply());
                break;

            case "/":
                Console.WriteLine(divider.Divide());
                break;

            case "^":
                Console.WriteLine(exponenter.Exponent());
                break;

            default:
                break;
            }
        }
예제 #3
0
        public TValue Update(TKey key, TValue value)
        {
            _deltas[key] = _subtractor.Subtract(value, _values[key]);
            _values[key] = value;

            return(_deltas[key]);
        }
예제 #4
0
 public T Subtract(T valueX, T valueY)
 {
     return(_subtractor.Subtract(valueX, valueY));
 }
예제 #5
0
 public int Subtract(int a, int b) => _subtractor.Subtract(a, b);
예제 #6
0
 public void Update(T value)
 {
     _delta = _subtractor.Subtract(value, _value);
     _value = value;
 }
예제 #7
0
 public void Handle(int firstNum, int secondNum)
 {
     adder.Add(firstNum, secondNum);
     subtractor.Subtract(firstNum, secondNum);
 }