| 61 | |
| 62 | @dataclass |
| 63 | class Rect: |
| 64 | top_left: Point |
| 65 | bot_right: Point |
| 66 | |
| 67 | def height(self) -> int: |
| 68 | return self.bot_right.y - self.top_left.y |
| 69 | |
| 70 | def width(self) -> int: |
| 71 | return self.bot_right.x - self.top_left.x |
| 72 | |
| 73 | def contains(self, point: Point) -> bool: |
| 74 | x_contained = self.top_left.x <= point.x and point.x <= self.bot_right.x |
| 75 | y_contained = self.top_left.y <= point.y and point.y <= self.bot_right.y |
| 76 | return x_contained and y_contained |
| 77 | |
| 78 | def random_point_inside(self) -> Point: |
| 79 | x = randint(self.top_left.x, self.bot_right.x) |
| 80 | y = randint(self.top_left.y, self.bot_right.y) |
| 81 | return Point(x, y) |
| 82 | |
| 83 | |
| 84 |
no outgoing calls
no test coverage detected