Question
Part 1 (15 points): Write a class called Polygon, which we will later use as a superclass to other classes. The polygon class should have
Part 1 (15 points):
Write a class called Polygon, which we will later use as a superclass to other classes. The polygon class should have a constructor that takes the number of sides as the only input, as well as __str__() and __eq__() methods.
The __str__() method should be written in a general enough format such that it can be used for the subclasses we will write later. When printed, an object of type Polygon should display the name of the Polygon (circle, rectangle, etc.) followed by the length of each side of the polygon.
The __eq__() method should also be written general enough such that it can be used for the subclasses. The method should check the value for each attribute of the Polygon object and compare this to each value in the polygon we want to check equality with. If all attributes are equal, the __eq__() method should return True, otherwise it should return False.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started