Example #1
0
        public double evaluate()
        {
            switch (op)
            {
            case '#':
                return(value);

            case '+':
                return(left.evaluate() + right.evaluate());

            case '*':
                return(left.evaluate() * right.evaluate());

            default:
                return(0);
            }
        }
Example #2
0
        public static double calculate(Node root)
        {
            if (root == null)
            {
                return(0);
            }

            return(root.evaluate());
        }
        public static double calculate(Node root)
        {
            if (root == null) return 0;

            return root.evaluate();
        }