mirror of
https://github.com/Rushilwiz/APCS.git
synced 2025-04-05 13:00:20 -04:00
52 lines
1000 B
Java
52 lines
1000 B
Java
/* TreeNode class for the AP Exams */
|
|
|
|
public class TreeNode
|
|
{
|
|
private Object value;
|
|
private TreeNode left, right;
|
|
|
|
public TreeNode(Object initValue)
|
|
{
|
|
value = initValue;
|
|
left = null;
|
|
right = null;
|
|
}
|
|
|
|
public TreeNode(Object initValue, TreeNode initLeft, TreeNode initRight)
|
|
{
|
|
value = initValue;
|
|
left = initLeft;
|
|
right = initRight;
|
|
}
|
|
|
|
public Object getValue()
|
|
{
|
|
return value;
|
|
}
|
|
|
|
public TreeNode getLeft()
|
|
{
|
|
return left;
|
|
}
|
|
|
|
public TreeNode getRight()
|
|
{
|
|
return right;
|
|
}
|
|
|
|
public void setValue(Object theNewValue)
|
|
{
|
|
value = theNewValue;
|
|
}
|
|
|
|
public void setLeft(TreeNode theNewLeft)
|
|
{
|
|
left = theNewLeft;
|
|
}
|
|
|
|
public void setRight(TreeNode theNewRight)
|
|
{
|
|
right = theNewRight;
|
|
}
|
|
}
|