I am trying to do the following exercise from a python textbook:
Write a definition for a class named Circle with attributes center and radius, where center is a Point object and radius is a number.
I have written the following code:
class Point:
def __init__(self , x , y):
self.x = x
self.y = y
class Circle:
def __init__(self , center , radius):
self.center = center
self.radius = radius
c = Point(0 , 0)
r = 75
c1 = Circle(c , r)
c2 = Circle((1 , 0) , 2)
This seems to work. But the thing is I have created the second Circle object c2
by specifying a tuple (1 , 0)
as the center which is not a Point object.
How do I make sure that the Circle class takes only Point object as the center
argument?