Write a subclass called Rcircle of the superclass Circle.
Circle__init__(self, r).Rcircle subclass must reimplement the radius function. It does not make sense for Rcircle to inherit the radius method from Circle since an instance of Rcircle doesn't know anything about the coordinates of the circle.__eq__ special method to compare two circles.Demo your class.
Your Circle class from last time should have looked something like this:
In [1]:
import numpy as np
class Circle:
def __init__(self, x, y):
self.x = x
self.y = y
def radius(self):
self.R = np.sqrt(self.x * self.x + self.y * self.y)
def area(self):
try:
self.A = np.pi * self.R* self.R
except AttributeError:
r = np.sqrt(self.x * self.x + self.y * self.y)
self.A = np.pi * r * r
def circum(self):
try:
self.C = 2.0 * np.pi * self.R
except AttributeError:
r = np.sqrt(self.x * self.x + self.y * self.y)
self.C = 2.0 * np.pi * r