# class Rectangle:
#     def __init__(self, length, width):
#         self.length = length
#         self.width = width
#
#     def area(self):
#         return self.length * self.width
#
#     def perimeter(self):
#         return 2 * self.length + 2 * self.width
#
#
# class Square:
#     def __init__(self, length):
#         self.length = length
#
#     def area(self):
#         return self.length * self.length
#
#     def perimeter(self):
#         return 4 * self.length
#

# Instead we can write
class Rectangle:
    def __init__(self, length, width):
        self.length = length
        self.width = width

    def area(self):
        return self.length * self.width

    def perimeter(self):
        return 2 * self.length + 2 * self.width


# Here we declare that the Square class inherits from the Rectangle class
class Square(Rectangle):
    def __init__(self, length):
        super().__init__(
            length=length, width=length
        )  # is equivalent to super(Square, self).__init__(length, length)


# square = Square(4)
#
# square.area()


class Cube(Square):
    def surface_area(self):
        face_area = super().area()  # super(Square, self).area()
        return face_area * 6

    def volume(self):
        face_area = super().area()
        return face_area * self.length


#
# cube = Cube(3)
# cube.surface_area()

# cube.volume()


# super in multiple inheritance
class Triangle:
    def __init__(self, base, height, **kwargs):
        self.base = base
        self.height = height

    def area(self):
        return 0.5 * self.base * self.height


#
# class RightPyramid(Triangle, Square):
#     def __init__(self, base, slant_height):
#         self.base = base
#         self.slant_height = slant_height
#
#     def area(self):
#         base_area = super().area()
#         perimeter = super().perimeter()
#         return 0.5 * perimeter * self.slant_height + base_area
#
# pyramid = RightPyramid(2, 4)
# pyramid.area()

# MRO

# Change the signature of inheritance
class RightPyramid(Square, Triangle):
    # __mro__ =
    def __init__(self, base, slant_height):
        self.base = base
        self.slant_height = slant_height
        super().__init__(self.base)

    def area(self):
        base_area = super().area()
        perimeter = super().perimeter()
        return 0.5 * perimeter * self.slant_height + base_area


RightPyramid.__mro__
pyramid = RightPyramid(2, 4)
# RightPyramid.__mro__
pyramid.area()
