Checkpoint

Checkpoint: The Lighthouse Crew

Each lighthouse in Pythonia has a crew of keepers. The head keeper carries the keys. The Guild wants classes that model a lighthouse and its crew.

This checkpoint uses the whole chapter: composition, inheritance with super(), a read-only @property and a @classmethod.

Keeper is ready.

Assignment

  1. HeadKeeper is a child class of Keeper.
    • Its __init__(self, name, keys) lets Keeper store the name, then stores keys.
    • Its describe() returns the parent's description plus with N keys, e.g. Ada the keeper with 3 keys.
  2. Lighthouse(island) stores island and starts an empty crew list.
    • hire(keeper) adds a keeper to the crew.
    • roster() returns a list with each keeper's describe() text, in hiring order.
    • size is a read-only property: the number of keepers.
  3. A class method Lighthouse.from_names(island, names) builds a lighthouse and hires a plain Keeper for each name.