Exemplo n.º 1
0
        public override int Calculate()
        {
            switch (Op)
            {
            case Operator.Mul:
                return(LeftNode.Calculate() * RightNode.Calculate());

            case Operator.Div:
                return(LeftNode.Calculate() / RightNode.Calculate());

            case Operator.Mod:
                return(LeftNode.Calculate() % RightNode.Calculate());

            case Operator.Plus:
                return(LeftNode.Calculate() + RightNode.Calculate());

            case Operator.Minus:
                return(LeftNode.Calculate() - RightNode.Calculate());

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 2
0
 public sealed override double Calculate() => LeftNode.Calculate() + RightNode.Calculate();
Exemplo n.º 3
0
 public sealed override int Calculate() => LeftNode.Calculate() - RightNode.Calculate();