Esempio n. 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);
            }
        }
Esempio n. 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();
        }