We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Get Edges

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.

Assignment

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.

Tips

You may find Python's built-in min and max functions useful. For example, min(3, 7) returns 3, and max(3, 7) returns 7.