java - Inherited method needs one more parameter -


I have a guardian class with many children, one of the children is an override method, which has its special internal use , Another parameter is required I do not want to change the signature of the law because the override system in other children does not require this parameter, I do not even want to add class properties as it is in vain in this case.

How do you deal with these situations?

So far, I have added an unchanged exception to the law and made a new one, but it is actually something I have done when I wait for an answer.


Edit after John Skeet's Answer

I will try to figure out whether I understood what John suggested, it is very interesting.

  Public abstract class guardian {public abstract zero aMethod (object parameter); } Public Class Non-Rallypolitized Child {Create Public Creators} (New Child Return); }} Public Nectar Class Children Extended Parents {}  

No Mmmmh, I am completely wrong here, I can not understand the second part of your post, Put some light on?

It seems that you do not really have any appropriate heritage - it breaks, because you Do not use this "child" as if it was an example of parents without any additional knowledge.

About not to remove the "children" class from "parents", but the child who will be create an example of some sub-classes of parent, which "Knows" the appropriate extra bit? If you can give us more information about the classes, then we can give more concrete examples of what the code looks like.

EDIT: It is very difficult to know what you are doing because it is more clear, but something like this:

Public class NautilPercleBuckled {public parent Create the Intestate (Object Extra Portamator) {New Childhood Parameter (Additional Permits); }

The child childWithParameter can then override the appropriate method without due to taking any additional information, because it is already It was part of its own internal status


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -