Tell us what’s happening:
Hi there,
On the Polygon Area Calculator, I have all tests passing bar one - An instance of the Square
class should have a different string representation after setting new values by using .set_width()
or set_height()
- but it works when I try it out manually.
Any clues?
Your code so far
```py
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def __str__(self):
return f"Rectangle(width={self.width}, height={self.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 (self.width + self.height) * 2
def get_diagonal(self):
return ((self.width ** 2) + (self.height ** 2)) ** .5
def get_picture(self):
picture = ""
if self.width > 50 or self.height > 50:
return "Too big for picture."
else:
picture += ("*" * self.width + "\n") * self.height
return picture
def get_amount_inside(self, shape):
return self.get_area() // shape.get_area()
class Square(Rectangle):
def __init__(self, side):
super().__init__(side, side)
def __str__(self):
if self.width == self.height:
return f"Square(side={self.width})"
else:
return f"Rectangle(width={self.width}, height={self.height})"
def set_side(self, side):
self.width = side
self.height = side
### Your browser information:
User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36</code>
### Challenge Information:
Scientific Computing with Python Projects - Polygon Area Calculator
https://www.freecodecamp.org/learn/scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator