AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
ExpressionTreeExample.java
Go to the documentation of this file.
1package aud.example.expr;
4
5 public static void main(String[] args) {
7 (new Times(),
9 (new Plus(),
10 new ExpressionTree(new Number(2)),
11 new ExpressionTree(new Number(3))),
12 new ExpressionTree(new Number(5))
13 ); // (2+3)*5
14 System.out.println(tree);
15 System.out.println(tree.getValue());
16 }
17}
ExpressionTree: minimal example.
Tree representation of arithmetic expression.
double getValue()
compute value of expression
Node representing constant number.
Definition: Number.java:6
binary + operator: A+B
Definition: Plus.java:4
binary * operator: A*B
Definition: Times.java:4