I just finished the Polygon Area Calculator project, and also enhanced it a little bit looking at some feedbacks.
The thing is, there’s still something I don’t fully understand. Part of the instructions said that " the
set_height methods on the Square class should set both the width and height."
Does this mean that when calling
square_object.set_width both attributes should change? Because if that’s the case, the only way I found to achieve it was to repeat the
set_width methods from the superclass, and make both return the
set_side method, which changes the width and lenght of the square to the same value:
def set_side(self, new_side): self.width = new_side self.height = new_side def set_height(self, new_height): return self.set_side(new_height) def set_width(self, new_width): return self.set_side(new_width)
Is there a more efficient way to do this? Or have I just missunderstood the instructions?
Thanks in advance! Here’s the link to my code, in case you wanna check it out: