-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTree.java
More file actions
37 lines (29 loc) · 697 Bytes
/
Tree.java
File metadata and controls
37 lines (29 loc) · 697 Bytes
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
34
35
36
37
package gp_project;
public class Tree implements Comparable<Tree> {
private double fitnessValue = 99999;
private Node m_rootNode;
public Tree(String rootData) {
m_rootNode = new Node(rootData, NodeType.OPERATOR);
}
@Override
public int compareTo(Tree other) {
if (other.getFitnessValue() > this.fitnessValue)
return 1;
else if (other.getFitnessValue() == this.fitnessValue)
return 0;
else
return -1;
}
public double getFitnessValue() {
return fitnessValue;
}
public Node getRootNode() {
return m_rootNode;
}
public void printTree() {
m_rootNode.printNode();
}
public void setFitnessValue(double fitnessValue) {
this.fitnessValue = fitnessValue;
}
}