Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I do not know how to do it and I cannot run it, so I need a help. This is

ID: 3665585 • Letter: H

Question

Hello, I do not know how to do it and I cannot run it, so I need a help. This is python3.

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.)

A method contains(circle2D) that returns True if the specified circle is inside this circle. (Hint: see Figure 2. Circle c1 contains circle c2 iff the distance between c1.radius and c2.radius + c2.radius <= c1.radius.)

A method overlaps(circle2D) that returns True if the specified circle overlaps with this circle. (Hint: see Figure 3. Circle c1 overlaps with circle c2 iff the distance between c1.radius and c2.radius < c1.radius + c2.radius.)

Implement the _ _contains_ _(self, anotherCircle) method that returns True if anotherCircle is contained in this circle. The _ _contains_ _(self, item) special method is used to implement the membership test operator in. It should return true if item is in self, and false otherwise.

Implement the _ _lt_ _, _ _le_ _, _ _gt_ _, _ _ge_ _, _ _eq_ _, and _ _ne_ _ methods that compare two circles based on their radii.

Explanation / Answer

import math class Circle2D(object): def __init__(self, x = 0, y = 0, r = 0): """Creates a circle with specified x, y, and radius.""" self._x = x self._y = y self._r = r def __str__(self): """Returns the string representation.""" return ("Circle with center" + "(" + "%0.0f" % (self._x) + ", " + "%0.0f" % (self._y) + ")" + "and radius " + "%0.0f" % (self._r)) def getX(self): """Returns the X value.""" return self._x def getY(self): """Returns the Y value.""" return self._y def getRadius(self): """Returns the value of the radius""" return self._r def setRadius(self): """Sets a new value for the radius.""" pass def getArea(self): """Returns the area of the circle.""" return math.pi * self._r * self._r def getPerimeter(self): """Returns the perimeter of the circle.""" return 2 * math.pi * self._r def containsPoint(x,y): """Returns True if the specified point (x, y) is inside this circle.""" if (self._x)^2 + (self._y)^2 = c2) print('c1 == "Hello"?', c1 == "Hello") print('c1 != "Hello"?', c1 != "Hello") main()
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote