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 initself corner, width, height:
self.corner corner
self.width width
self.height height
def calculatecornersself:
# Calculate the top right corner
topright Pointselfcorner.x self.width, self.corner.y
bottomleft Pointselfcorner.x self.corner.y self.height
bottomright Pointselfcorner.x self.width, self.corner.y self.height
return selfcorner.x self.corner.ytopright.x topright.ybottomleft.x bottomleft.ybottomright.x bottomright.y
def increasesizeself n:
self.width n
self.height n
def initself size cornerPoint:
self.corner corner
self.width size
self.height size
def ispointinsideself point:
return selfcorner.x point.x self.corner.x self.width and selfcorner.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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
