Question
For this next exercise, write a Circle class. As you may recall, objects usually have attributes that store useful information. A Bank Account might have
For this next exercise, write a Circle class. As you may recall, objects usually have attributes that store useful information. A Bank Account might have a balance attribute, a Car would likely have the number of miles driven, a TV might have a screen size, etc. For our circle class, we will only have a radius. In addition to the radius attribute, the circle class should have the following methods/constructors:
- A constructor that takes in the radius.
- A method getRadius, which returns the radius of the circle.
- A method setRadius, which sets the radius of the circle.
- A method getArea, which returns the area of the circle.
- A method getDiameter which returns the diameter of the circle.
- A method getCircumference which returns the circumference of a circle.
- If it is possible in your language, override the equality operator (==) in Python its the __eq__ method. You should return True if the radii are equal.
Create two circles with some radius. Display their areas, diameters, and circumferences. Also, test the equality of the two circles.
(In Python)
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