

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
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
In the last chapter we checked if a unit's (x, y) point was within a rectangle (the Dragon's breath). But units aren't really points - they have their own areas.
So we're going to check if a dragon's body (a rectangle) is within the fire (also a rectangle). The image below contains an example of fire breath hitting a dragon.
Later we'll write the overlap method, but first we'll just write a method to find the edges of a rectangle.
We changed the coordinates themselves to be private by adding two underscores to them. We now need to write getter methods to access them.
Complete the following methods:
Remember that we're working with a standard Cartesian plane.
We will explain the __repr__ method later, don't worry too much about it.