Question: Design and implement a class named Circle2D that contains: Two data fields (i.e., instance variables) named x and y that specify the center of the
Design and implement a class named Circle2D that contains: Two data fields (i.e., instance variables) named x and y that specify the center of the circle. A data field radius with get/set methods. The method getRadius() returns the value of the radius while setRadius() sets a new value for the radius. A constructor (i.e., __init__ method) that creates a circle with specified x, y, and radius. Use the default value 0 for all parameters. An __str__ method that return a string representation of the form "Circle with center (x, y) and radius radius", where x, y, and radius will be replaced by the circle's actual values of the center and raduis. For example, on a circle object with center at (2, 3) and radius 10, this method will return the string "Circle with center (2, 3) and radius 10". A getX() and getY() methods. A method getArea() that returns the area of the circle. A method getPerimeter() that returns the perimeter of the circle. A method containsPoint(x, y) that returns True if the specified point (x, y) is inside this circle. (Hint: see Figure 1. A point P is inside the circle c iff distance between c.center and P is less than c.radius.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
