I've got two class: GraphNode and BTNode extends GraphNode. I've got method:
public GraphNode.addChild(GraphNode node) as GraphNode may have many children and two methods:
public BTNode.addLeftChild(BTNode left) public BTNode.addRightChild(BTNode right) as BTNode may have only two children
How may I restrict public access to inherited addChild(GraphNode node) method from BTNode class? I wouldn't like to have that publicly accessible from that level (while remaining public access from GraphNode class)?
addChildand have it throw an exception with a good error message that explains why this method shouldn't be used here and what should be used instead. Now, all that said, maybe you should re-consider inheritance, because it feels thatBTNodedoesn't have that much in common withGraphNodeafter all...