

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 9
click for more info
Not enough gems
Cost: 6 gems
1: Polymorphism
incomplete
2: Get Edges
incomplete
3: Overlap
incomplete
4: Dragon Area
incomplete
5: Polymorphism Review
incomplete
6: Operator Overloading
incomplete
7: Operator Overload Review
incomplete
8: Overriding Built-in Methods
incomplete
9: Polymorphism Practice
incomplete
10: Polymorphism Practice
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Time to write the logic that determines if two rectangles overlap!
Complete the overlaps(self, rect: "Rectangle") -> bool method. It should check if the current rectangle (self) overlaps a given rectangle (rect).
Return True if self overlaps any part of rect, including just touching sides. Return False otherwise.
Each comparison has two parts:
self and one edge from rectFor example, to check if self's left side is on or to the left of rect's right side, compare self's left edge getter to rect's right edge getter.
All four of these conditions must be True:
self's left side is on or to the left of rect's right sideself's right side is on or to the right of rect's left sideself's top side is on or above rect's bottom sideself's bottom side is on or below rect's top side