package edu.claflin.finder.algo.huffman;

import edu.claflin.finder.logic.Node;

//Class for a Huffman node.
public class HuffmanNode {
    private String name; //This will give us the name of the node or the string associated with it.
    private int freq; //This will store the frequency of the nodes.
    private HuffmanNode left; //The node's left child.
    private HuffmanNode right; //The node's right child.

    //Sets the frequency of the Huffman node.
    public void setFreq(int freq) {
        this.freq = freq; //Assigns the frequency given in the method to the frequency of the Huffman node.
    }

    //Sets the name of the Huffman node. Name should come from the getIdentifier() method in the Node class.
    public void setName(String name) {
        this.name = name; //Assigns the name given in the method to the Huffman node's name.
    }

    //Sets the left child of the Huffman node to another Huffman node.
    public void setLeft(HuffmanNode node) {
        left = node;
    }

    //Sets the right child of the Huffman node to another Huffman node.
    public void setRight(HuffmanNode node) {
        right = node;
    }

    //Returns the name or identifier of the Huffman node.
    public String getName() {
        return name;
    }

    //Returns the frequency of the Huffman node.
    public int getFreq() {
        return freq;
    }

    //Returns the left child of the Huffman node.
    public HuffmanNode getLeft() {
        return left;
    }

    //Returns the right child of the Huffman node.
    public HuffmanNode getRight() {
        return right;
    }

    public void incrementFrequency(){
        freq++;
    }
}
