Final OOP Capstone
Final OOP Capstone
Great job finishing this module.
Now it is time to build one real project using everything you learned in OOP.
Project: Library Management System
Build a program that manages books using classes and objects.
You will use:
- classes
- objects
- attributes
- methods
__init__()- encapsulation
- inheritance
- polymorphism
Step 1: Create the Parent Class
Create a class named:
LibraryItem
Use __init__() with:
- title
- year
Add method:
show_info()
It should print title and year.
Step 2: Create Child Classes
Create these child classes:
Book
Extra attribute:
- author
Method:
borrow()
Print:
Book borrowed
Magazine
Extra attribute:
- issue_number
Method:
borrow()
Print:
Magazine borrowed
Step 3: Create Objects
Create:
book1 = Book("Python Basics", 2024, "John Smith")
mag1 = Magazine("Tech Monthly", 2025, 12)
Step 4: Show Information
Call:
show_info()borrow()
Expected output:
Python Basics 2024
Book borrowed
Tech Monthly 2025
Magazine borrowed
Step 5: Use Polymorphism
Create a list:
items = [book1, mag1]
Use a loop and call:
item.borrow()
Expected output:
Book borrowed
Magazine borrowed
Step 6: Add Encapsulation
Create a protected attribute:
_status
Start with:
Available
When borrowed, change it to:
Borrowed
Create method:
show_status()
Full Example Run
Python Basics 2024
Available
Book borrowed
Borrowed
Tech Monthly 2025
Magazine borrowed
Extra Challenges
After finishing, try adding:
- Return item
- Search by title
- Add more item types
- Save to file
- Member system
- Late fee system
Real World Use Case
OOP is used in library systems, stores, booking apps, games, and inventory software.
Assignment
Build the full project. Then add one extra feature.
Summary
You built a complete OOP application using classes, inheritance, polymorphism, methods, and encapsulation.