← Back to course
Python 11-12 / Week 07 / Mission Quest
6/6
Week 07 · The Fleet

Mission Quest

Mission Quest: A family tree of kinds
// Subclasses reuse and override; one call, many behaviors
⏱ about 30 min

Saturday: Mission Quest: A Family Tree of Kinds

On Saturday the crew sorts the maker space storage shelf. Comet pulls down a toolbox, a sewing kit and a laundry basket.

"These are all containers," she says. "They all open, close and hold things. But each one is a bit different."

Wren starts a list. "What does the evidence say? Write what they all share at the top. Write only the differences underneath."

Nova projects an empty tree on the wall: one box at the top and two below. "How can I help?" she asks. "Find what stays the same, and what each kind changes."

Comet hands you a marker. "Lead programmer, take this home and build a tree with your family."

◇ A FAMILY TREE OF KINDS
You need: paper, a pencil and three containers from around your home, such as a box, a bag and a basket.
1. Pick a base kind, such as "container". With a family member, list what every container has and does: it has a size, it opens, it holds things.
2. Pick two subkinds, such as "toolbox" and "laundry basket". Draw them as two boxes under the base box, joined by lines.
3. In each subkind box, write only what it changes or adds. For example, a toolbox might add "has trays" and change "opens" to "opens with a latch".
4. Circle anything a subkind changes. Those are overrides.
5. Swap roles: your family member picks a new base kind, like "seat", and you name two subkinds and their overrides.
For a grown-up
This activity practices this week's idea without a computer. A subclass keeps what its base class has and overrides only what is different.
Ask your learner: "What would we have to write again if the toolbox did not start from container?" There is no single right tree.

Back at FieldSim, the same tree holds the fleet: Rover at the top, ScoutRover and HaulerRover underneath, each overriding step_use() and status().

WEEK 7 RECAP
  • Read the question.
  • Tap your answer.
In your tree, the toolbox "opens with a latch" instead of just "opens". What is that called in code?
Which line makes HaulerRover start from Rover?
Moss is a HaulerRover. What does moss.step_use() give?
StatementTrue or false?
A subkind lists everything the base kind already has, again.?
super().status() lets a subclass extend the base status() line.?
A ScoutRover is an instance of Rover too.?
WHY THIS EXERCISEInheritance keeps shared behavior in one place, and super() lets a subclass build on it.

Great work this week. You built a fleet on one trusted class. Next week the crew starts searching the sample catalog.

← Friday