Deveoping a function that finds a common intersection between an array of rectangles however the method return False when it should be true. The function calls to the intersect function in the class rectangle. Any suggestions.
Class Rectangle:
def intersects(self, other):
"""Return true if a rectangle intersects the other rectangle."""
return (self.top_right.x > other.bottom_left.x and self.bottom_left.x < other.top_right.x and self.bottom_left.y < other.top_right.y and self.top_right.y > other.bottom_left.y)
Class Many_Rect:
def common_point(self):
value = False
for i in range(len(self.rectangles) - 2):
for j in range(len(self.rectangles) - 1, -1, -1):
if self.rectangles[i].intersects(self.rectangles[j]) == True:
value = True
else:
return False
return True