Classes Rectangle and Point are defined as follow:
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
class Rectangle:
def __init__(self,p1,p2):
self.p1 = p1
self.p2 = p2
Which option is showing the correct way of calculating the area of the rectangle in the Rectangle class?
a) def area():
return (self.p1.x-self.p2.x) * (self.p1.y-self.p2.y)
b) def area(self):
return (self.p1.x-self.p2.x) * (self.p1.y-self.p2.y)
c) def area(self,p1,p2):
return p1.x-p2.x*p1.y-p2.y
d) def area(p1,p2):
return area(p1*p2)