How best to implement inheritance?

Hello.

Deal with inheritance in OOP. Wrote the code and feel that the method of inheritance can be rewritten competently. But knowledge is not enough. Help, please.
PS. Is it possible in inherited class to specify all the attributes of the superclass?

import math

class Figure():
 "'the determination of the parameters of the figure"'

 def __init__(self, radius, lenght, height):
 self.radius = radius
 self.lenght = lenght
 self.height = height

class Circle(Figure):
 "'calculate the parameters of a circle"'
 def __init__(self, radius, lenght=0):
 super().__init__(radius, lenght)
 self.pi = math.pi

 def areaCircle(self):
 """the area of a circle"""
 area = self.pi * self.radius ** 2
print(area)
 def lenghtCircle(self):
 """circumference"""
 lenght = 2 * self.pi* self.radius
print(lenght)


class Rectangle(Figure):
 """calculate the parameters of the rectangle"""
 def __init__(self, lenght, height, radius = 0):
 super().__init__(radius,lenght, height)

 def areaRectangle(self):
 """the area of a rectangle"""
 area = self.lenght * self.height
print(area)

 def perimeterRectangle(self):
 """perimeter of rectangle"""
 perimeter = 2* (self.height+self.lenght)
print(perimeter)

my_rectangle = Rectangle(3,4)
my_rectangle.perimeterRectangle()
March 12th 20 at 08:43
1 answer
March 12th 20 at 08:45
Sucks inheritance. SOLID read, especially the item that L

Find more questions by tags Python