Build a Polygon Area Calculator - Build a Polygon Area Calculator

Tell us what’s happening:

What should I do for no.16. I dont know what to do with it

Your code so far

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height
        
    def set_width(self, width):
        self.width = width
    def set_height(self, height):
        self.height = height
    def get_area(self):
        return (self.width * self.height)
    def get_perimeter(self):
        return 2 *(self.width + self.height)
    def get_diagonal(self):
        return ((self.width**2 + self.height**2 )**0.5)
    def get_picture(self):
        if self.width > 50 or self.height > 50:
            return 'Too big for picture.'
        else:
            picture = ''
            for i in range(0, self.height):
                picture += '*' * self.width + '\n'
            return picture

    def get_amount_inside(self, shape):
        times = 0
        if (shape.width < self.width) and (shape.height < self.height):
            times = (self.width // shape.width) * (self.height // shape.height)
            return times
        else: 
            times = 0
            return times

    def __str__(self):
        return f'Rectangle(width={self.width}, height={self.height})'
    
    
class Square(Rectangle):
    def __init__(self, side):
        super().__init__(side, side)

    
    def set_side(self, side):
        self.width = side 
        self.height = side 
  
    def set_width(self, width):
        self.width = side 

    def set_height(self, height):
        self.height = side

    def __str__(self):
        return f'Square(side={self.width})'


rect = Rectangle(10, 5)
print(rect.get_area())
rect.set_height(3)
print(rect.get_perimeter())
print(rect)
print(rect.get_picture())

sq = Square(9)
print(sq.get_area())
sq.set_side(4)
print(sq.get_diagonal())
print(sq)
print(sq.get_picture())

rect.set_height(8)
rect.set_width(16)
print(rect.get_amount_inside(sq))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0

Challenge Information:

Build a Polygon Area Calculator - Build a Polygon Area Calculator

Take another look at the 6th user story and requirements regarding these methods.