package trees;

// Declarations for a typical tree-node class
// For a binary search tree, data in nodes must have a comesBefore method
// as well as an equal method.  This node therefore uses the Entry class 
// for data storage.

import schoolDirectory.Entry; 

public class TreeNode {

    protected Entry data;      // the information to be stored in the node
    protected TreeNode left;   // the pointer to the node's left subtree
    protected TreeNode right;  // the pointer to the node's right subtree

    // Constructors
    public TreeNode (Entry startingData) {
        data = startingData;
        left = null;
        right = null;
    }

    public TreeNode (Entry initData, TreeNode leftNode, TreeNode rightNode) {
        data = initData;
        left = leftNode;
        right = rightNode;
    }

    // extractors
    public Entry getData () {
        return data;
    }

    public TreeNode getLeft () {
        return left;
    }

    public TreeNode getRight () {
        return right;
    }

    // modifiers
    public void setData (Entry newData) {
        data = newData;
    }

    public void setLeft (TreeNode newLeft) {
        left = newLeft;
    }
    public void setRight (TreeNode newRight) {
        right = newRight;
    }
} // TreeNode

