samedi 3 janvier 2015

How to share methods in derived classes without including in base class

I have a class BinarySearchTree which is extended by AVLTree and RedBlackTree. The two derived classes support rotation hence need to use rotateLeft and rotateRight method. One way is to implement these two methods in BinarySearchTree so that they are available to AVLTree and RedBlackTree, but these methods do not belong to BinarySearchTree as it does not support rotation as such. How should I handle this situation in Java?


Aucun commentaire:

Enregistrer un commentaire