public void Calculate(IDoubleNumericalOperation numericalOperationRequest)
 {
     if (numericalOperationRequest.OperationType == _operationType)
     {
         var result = numericalOperationRequest.First * numericalOperationRequest.Second;
         Console.WriteLine($"Multiplying two numbers {numericalOperationRequest.First} and {numericalOperationRequest.Second}. Result is {result}.");
     }
     else
     {
         _nextCalculatorChain.Calculate(numericalOperationRequest);
     }
 }
示例#2
0
 public void Calculate(IDoubleNumericalOperation numericalOperationRequest)
 {
     if (numericalOperationRequest.OperationType == _operationType)
     {
         if (numericalOperationRequest.Second == 0.0)
         {
             throw new DivideByZeroException();
         }
         var result = numericalOperationRequest.First / numericalOperationRequest.Second;
         Console.WriteLine($"Dividing two numbers {numericalOperationRequest.First} and {numericalOperationRequest.Second}. Result is {result}.");
     }
     else
     {
         _nextCalculatorChain.Calculate(numericalOperationRequest);
     }
 }