summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/BinTreeNode.java
blob: 7903ef17dc531fbd1e100788435dd7f2cb44d035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* BinTreeNode.java */

class BinTreeNode
implements Cloneable
{
  String      name;
  BinTreeNode leftChild;
  BinTreeNode rightChild;

  public BinTreeNode(String name)
  {
    this.name       = name;
    this.leftChild  = null;
    this.rightChild = null;
  }

  public Object clone()
  {
    try {
      BinTreeNode newNode = (BinTreeNode)super.clone();
      if (this.leftChild != null) {
        newNode.leftChild = (BinTreeNode)this.leftChild.clone();
      }
      if (this.rightChild != null) {
        newNode.rightChild = (BinTreeNode)this.rightChild.clone();
      }
      return newNode;
    } catch (CloneNotSupportedException e) {
      //Kann eigentlich nicht auftreten...
      throw new InternalError();
    }
  }
}