Yes, both files (HuffmanTree.java and HuffmanCharFreqs.java) need compareTo() methods. I feel like I'm wrong, though, so someone check me on that. You don't *have* to, though, since for example, my algo does not require the compareTo() method in both, but then again, I end up barely using HuffmanTree.java at all (which is a bad sign, even if my algo works).
Also: you don't need to detect if the object is a HuffmanTree type or not since you'll know that or else the proper compareTo() method in the proper file (HuffmanTree.java or HuffmanCharFreqs.java) could not be detected.
Casting should solve the problem of "detecting if the object is a HuffmanTree type or a HuffmanCharFreqs type." |