CoursePython from Scratch to Intermediate · Module 9: Classes and Objects · part 61 of 75
Part 61 · Module 9: Classes and Objects

Lesson 2: Designing classes that work together

19 min read·14 Oct 2026
Module 9 · Lesson 2 · About 50 minutes · Needs: Module 9 Lesson 1 (class, __init__, self, methods), Module 8 (raising and catching errors), Module 7 (the booknook package, date)

The situation

Lesson 1 gave you four classes: Book, Member, Loan and Library. Now Amira wants them to behave like the shelf. Kwame has three books out on Wednesday 14 October, so the program must refuse him a fourth. Nobody may borrow Emma while Sofia has the only copy. And she has a new book for the café: a thesaurus that stays at the counter and is never lent.

That is a design job: which class holds which fact, and when one class should be a special kind of another.

REQUESTS AT THE COUNTER, 14 OCTOBER Library lend(...) checks the rules Kwame: Holmes refused Priya: Emma refused Lena: thesaurus refused Ben: Holmes lent, L41
By the end of the lesson the Library (blue, your code) refuses Kwame's fourth book, a book with no copy left and the reference thesaurus (red), and lends to Ben (green).

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.