Capstone · 10 min read · Beginner
OOP Capstone: Modular Library System
Combine encapsulation, composition, polymorphism, and SOLID principles to build a clean Library checkout system.
What you'll learn
- Design collaborating classes with clear single responsibilities
- Protect item availability with encapsulation
- Prepare for the OOP Final Exam and Certificate
In this capstone, you will combine all four pillars of OOP into a clean, extensible Library System:
- Encapsulation:
Bookprotects#checkedOutso books cannot be double-borrowed. - Polymorphism: Different
FinePolicyclasses compute late fees differently. - Composition & DI:
Librarycomposes a catalog and aFinePolicy.
Fill-in-the-Blank Capstone
Encapsulated Checkout Guard
Prevent borrowing a book that is already checked out.
class Book {
#checkedOut = false;
borrow() {
if (this.) return false;
this.#checkedOut = ;
return true;
}
}Capstone Playground
Modular OOP Library System
Live Result
Console Output
No console output yet. Try calling console.log(...) in JS.
Check Your Understanding
Score: 0 / 1
1. In the Library capstone, why is FinePolicy passed into Library's constructor instead of hardcoded?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.