示例#1
0
        public override double Calculate()
        {
            var rightOperandResult = RightOperand.Calculate();

            if (rightOperandResult.Equals(0))
            {
                throw new DivideByZeroException();
            }

            return(LeftOperand.Calculate() / RightOperand.Calculate());
        }
示例#2
0
        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);
        }
示例#3
0
 public override double Calculate()
 {
     return(Math.Pow(LeftOperand.Calculate(), RightOperand.Calculate()));
 }
示例#4
0
 public override double Calculate()
 {
     return(LeftOperand.Calculate() + RightOperand.Calculate());
 }