Build a Polygon Area Calculator - Build a Polygon Area Calculator

Tell us what’s happening:

I am stuck with the test number 14: An instance of the Rectangle class should have a different string representation after setting new values.

Even though my script seem to provide the expected result. WhAt DoEs iT want FroM mE? Somebody help please, Anybody.

Your code so far

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height
   
    @property
    def width (self):
        return self._width

    @width.setter
    def width (self, new_width):
        if new_width < 0:
            raise ValueError("Width must be positive")
        self._width = new_width

    @property
    def height (self):
        return self._height

    @height.setter
    def height (self, new_height):
        if new_height < 0:
            raise ValueError("Height must be positive")
        self._height = new_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."
        picture = ""
        for w in range(self._height):
            picture += "*"*self._width + "\n"
        return picture
    
    def get_amount_inside (self, other_shape):
        return (self._width // other_shape.width)*(self._height // other_shape.height)

    def __str__(self):
        return f"Rectangle(width={self.width}, height={self.height})"


class Square(Rectangle):
    def __init__(self, side_length):
        self.width = side_length
        self.height = side_length

    @property
    def width (self):
        return self._width

    @width.setter
    def width (self, new_length):
        if new_length < 0:
            raise ValueError("Length must be positive")
        self._width = new_length
        self._height = new_length

    @property
    def height (self):
        return self._height

    @height.setter
    def height (self, new_length):
        if new_length < 0:
            raise ValueError("Length must be positive")
        self._height = new_length
        self._width = new_length
    
    @property
    def side_length (self):
        return self._width

    @side_length.setter
    def side_length (self, new_side):
        if new_side < 0:
            raise ValueError("Side must be positive")
        self._height = new_side
        self._width = new_side

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


shape1 = Rectangle(2, 8)
print(shape1)
shape1.width = 50
shape1.height = 10
print(shape1)




Challenge Information:

Build a Polygon Area Calculator - Build a Polygon Area Calculator

Please do not create duplicate topics for the same challenge/project question(s). If you need more help then respond back to the original topic you created with your follow up questions and/or your updated code and question.

The duplicate topic has been unlisted.

Thank you.

I have resolved the tests. Cheers!