AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
AtomicExpression.java
Go to the documentation of this file.
1
package
aud.example.expr;
2
6
public
abstract
class
AtomicExpression
{
13
protected
ExpressionTree
node_
=
null
;
14
16
public
boolean
isOperator
() {
return
!
isTerminal
(); }
18
public
boolean
isTerminal
() {
return
node_
.
isLeaf
(); }
19
21
public
enum
Type
{
22
OpPlus, OpMinus, OpUnaryMinus, OpTimes,
OpDivide
, OpPower,
23
TNumber
, TSymbol
24
}
26
public
abstract
Type
getType
();
27
29
@Override
public
AtomicExpression
clone
() {
30
// Note that this should be an abstract method!
31
//
32
// The implementation that throws an exception frees us from
33
// defining clone(), e.g., in the new Power class (expect less
34
// suprises.)
35
//
36
// Similarly, AtomicExpression should better implement
37
// Cloneable; but then we always had to take care of possible
38
// exception (CloneNotSupportedException).
39
throw
new
RuntimeException(
"You didn't overwrite clone()!"
);
40
}
41
45
public
abstract
double
getValue
();
46
}
aud.BinaryTree.isLeaf
boolean isLeaf()
Is this a leaf?
Definition:
BinaryTree.java:96
aud.example.expr.AtomicExpression
Superclass for data associated with a tree node.
Definition:
AtomicExpression.java:6
aud.example.expr.AtomicExpression.node_
ExpressionTree node_
uplink reference to node: node_.getData()==this @endiliteral
Definition:
AtomicExpression.java:13
aud.example.expr.AtomicExpression.getValue
abstract double getValue()
get value
aud.example.expr.AtomicExpression.getType
abstract Type getType()
Get type identifier.
aud.example.expr.AtomicExpression.clone
AtomicExpression clone()
Get a copy: a new AtomicExpression of same type/content.
Definition:
AtomicExpression.java:29
aud.example.expr.AtomicExpression.isTerminal
boolean isTerminal()
node represents number or symbol
Definition:
AtomicExpression.java:18
aud.example.expr.AtomicExpression.isOperator
boolean isOperator()
node represents operator
Definition:
AtomicExpression.java:16
aud.example.expr.ExpressionTree
Tree representation of arithmetic expression.
Definition:
ExpressionTree.java:14
aud.example.expr.AtomicExpression.Type
type identifiers returned by getType
Definition:
AtomicExpression.java:21
aud.example.expr.AtomicExpression.Type.OpDivide
OpDivide
Definition:
AtomicExpression.java:22
aud.example.expr.AtomicExpression.Type.TNumber
TNumber
Definition:
AtomicExpression.java:23
example
expr
AtomicExpression.java
Generated on Tue Apr 15 2025 13:46:54 for AuD by
1.9.5