I'm writing a HuffmanTree class for a Java project that inherits from a BinaryNode class. I want to work with HuffmanTree nodes instead of BinaryNode nodes. BinaryNode has left and right instance variables of type BinaryNode, and I want HuffmanTree to have the same instance variables (i.e. left and right), but of type HuffmanTree instead.
How would I go about doing this? Thanks!
EDIT: Here's some of the BinaryNode code:
public class BinaryNode<T> implements BinaryNodeInterface<T>,
java.io.Serializable
{
//The BinaryNode's instance variables were changed to protected so we can access them
//from the HuffmanTree class.
private T data;
private BinaryNode<T> left;
private BinaryNode<T> right;
public BinaryNode()
{
this(null); // call next constructor
} // end default constructor
public BinaryNode(T dataPortion)
{
this(dataPortion, null, null); // call next constructor
} // end constructor
public BinaryNode(T dataPortion, BinaryNode<T> leftChild,
BinaryNode<T> rightChild)
{
data = dataPortion;
left = leftChild;
right = rightChild;
} // end constructor