public override double Calculate() { var rightOperandResult = RightOperand.Calculate(); if (rightOperandResult.Equals(0)) { throw new DivideByZeroException(); } return(LeftOperand.Calculate() / RightOperand.Calculate()); }
public override double Calculate() { double leftValue = LeftOperand.Calculate(); double rightValue = RightOperand.Calculate(); switch (Operation) { case "*": value = leftValue * rightValue; break; case "+": value = leftValue + rightValue; break; case "^": value = Math.Pow(leftValue, rightValue); break; case "/": value = leftValue / rightValue; break; case "-": value = leftValue - rightValue; break; default: throw new Exception("Неизвестный бинарный оператор " + Operation); } return(value); }
public override double Calculate() { return(Math.Pow(LeftOperand.Calculate(), RightOperand.Calculate())); }
public override double Calculate() { return(LeftOperand.Calculate() + RightOperand.Calculate()); }