Answer the question
In order to leave comments, you need to log in
How to create a method for parent class?
There is a rectangle class. It is necessary to rewrite it so that it inherits from the Geometric figure class. Fields involve center coordinates. And make the draw method in the parent class.
With the fields, everything is simple and clear. But the method, it also uses other fields that are available only in the Rectangle class (width and height), how can I write a drawing method without using them? Somehow it doesn't work very well. It turns out that the parent method must somehow learn about the heir. What is wrong. But how then to implement the general method of drawing?
Answer the question
In order to leave comments, you need to log in
How to create a method for parent class?literally, no way. in the descendant, you can add methods and/or override. but it is impossible to create a method for the parent from the child
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question