Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Point(object):
- def __init__(self, coords):
- self.x = coords[0]
- self.y = coords[1]
- class Rectangle(object):
- def __init__(self):
- self.topRight = None
- self.topLeft = None
- self.bottomRight = None
- self.bottomLeft = None
- def inside(self, point):
- if point.x > self.topLeft.x and point.x > self.bottomLeft.x:
- if point.x < self.topRight.x and point.x < self.bottomRight.x:
- if point.y > self.topLeft.y and point.y < self.bottomLeft.y:
- return True
- return False
- p1 = Point((0,0))
- p2 = Point((2,0))
- p3 = Point((0,2))
- p4 = Point((2,2))
- testP1 = Point((1,1))
- testP2 = Point((3,3))
- rect = Rectangle()
- rect.topLeft = p1
- rect.topRight = p2
- rect.bottomRight = p4
- rect.bottomLeft = p3
- print(rect.inside(testP1))
- print(rect.inside(testP2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement