Tell us what’s happening:
I did all the tests and get one error " (An instance of the Square class should have a different string representation after setting new values by using .set_width() or set_height().)" any one explain it :>
Your code so far
class Rectangle:
# Takes variables(width , height)
def __init__(self, width, height):
self.width = width
self.height = height
# Makes readable content
def __str__(self):
if self.width == self.height:
return f"Square(side={self.height})"
else:
return f'Rectangle(width={self.width}, height={self.height})'
# Set a new width
def set_width(self,width):
self.width = width
# Set a new height
def set_height(self,height):
self.height = height
# Calc the area
def get_area(self):
return self.width * self.height
# Calc the perimeter
def get_perimeter(self):
return 2 * self.width + 2 * self.height
# Calc the diagonal
def get_diagonal(self):
return ((self.width ** 2 + self.height ** 2) ** .5)
# Make a picture of the shape
def get_picture(self):
if self.width > 50 or self.height > 50:
return "Too big for picture."
picture = ''
for i in range(self.height):
picture += '*' * self.width
picture += '\n'
return picture
# Get amount of shape that can fit inside the Rectangle
def get_amount_inside(self,shape):
return (self.height // shape.height) * (self.width // shape.width)
class Square(Rectangle):
# Take a vaiable and append it into Rectangle class
def __init__(self,side):
super().__init__(width=side,height = side)
# Set a new Side
def set_side(self,side):
super().__init__(width=side,height = side)
Challenge Information:
Build a Polygon Area Calculator Project - Build a Polygon Area Calculator Project