You could create subclass F to extend A, and then have B and C extend F
instead of A. Then stick the methods in F.
But this could drive you crazy and not work if you have various groupings
of shared methods, since java does not allow multiple inheritance.
Another approach would be to put the methods in A, and begin them with
something like:
if (!((this instanceof B)||(this instanceof C)))
{
throw new exception ("MethodX may only be invoked by classes B and C!!!");
}
-- Curt Springer, Team NetDynamics
At 08:17 AM 4/8/99 -0800, [EMAIL PROTECTED] wrote:
>Hi,
>I have a superclass A, from which I've derived 4 sub-classes, B,C,D and E.
Now the
> superclass has 4 methods. I need to add 2 more methods for sub-classes B
and C in
> the super class. But these methods are not needed by A and D. How do I
get around
> this? Is it enough to make the 2 methods protected?
>Thanks.
>Sushovan.
>
>_________________________________________________________________________
>
>For help in using, subscribing, and unsubscribing to the discussion
>forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
>For dire need help, email: [EMAIL PROTECTED]
>
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]