Question: Modify the Rectangle class below and add a method that takes a circle as an argument and determines if it is inside the its boundaries:

Modify the Rectangle class below and add a method that takes a circle as an argument and determines if it is inside the its boundaries: class Rectangle:
def __init__(self, corner, width, height):
self.corner = corner
self.width = width
self.height = height
def calculate_corners(self):
# Calculate the top right corner
top_right = Point(self.corner.x + self.width, self.corner.y)
bottom_left = Point(self.corner.x, self.corner.y + self.height)
bottom_right = Point(self.corner.x + self.width, self.corner.y + self.height)
return [(self.corner.x, self.corner.y),(top_right.x, top_right.y),(bottom_left.x, bottom_left.y),(bottom_right.x, bottom_right.y)]
def increase_size(self, n):
self.width += n
self.height += n
def _init__(self, size=10, corner=Point(0,0)):
self.corner = corner
self.width = size
self.height = size
def is_point_inside(self, point):
return (self.corner.x <= point.x <= self.corner.x + self.width) and (self.corner.y <= point.y <= self.corner.y + self.height)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!