U
U
up72020-05-25 15:51:03
OOP
up7, 2020-05-25 15:51:03

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

2 answer(s)
#
#, 2020-05-25
@up7

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

2
2CHEVSKII, 2020-05-25
@2chevskii

https://docs.microsoft.com/ru-ru/dotnet/csharp/lan...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question