Polygon Area Calculator

I am stuck, since I am passing all of the tests expect test_get_amount_inside. For some reason, sq isn’t updating to 2, but there is no error coming up saying that it couldn’t find a function. I’ve added print to the set_side function, but nothing seems to call upon it. So I am thinking it is an issue with my knowledge of Inheritance but I am not sure.
Link: https://repl.it/@SpencerSahu/fcc-shape-calculator

1 Like

Looks like you pasted the wrong link, can you paste the correct one?

I also edited the original post


    return( min(self.width // Shape.width, self.height//Shape.height) )

THis line, I believe, is what is throwing off your calculations. Currently, you compare the width of each shape and the height of each shape, and return the minimum of the two. What this means is - if I have a rectangle that is 2 units in height and 10 units in width, I should be able to fit 20 squares of 1 unit in height within the rectangle. But your code will say that I can fit 2 squares, based on the height of the square and the rectangle.

Hey @Saheasy ,
I agree with @nhcarrigan you’ve to take care of the area inside. A naive approach would be as below:

def get_amount_inside(self, shape):
        areaGuest = shape.get_area()
        areaHome = self.get_area()
        i = 0
        while areaHome>=areaGuest:
            areaHome = areaHome-areaGuest
        return i  

Thanks. I hope it helps.

Thank you two, I fixed it by using the area instead of the height and width.