CodingNic

Object-Oriented Programming

Final OOP Capstone

Object-Oriented Programming 60 min read

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:

python
LibraryItem

Use __init__() with:

  • title
  • year

Add method:

python
show_info()

It should print title and year.


Step 2: Create Child Classes

Create these child classes:

Book

Extra attribute:

  • author

Method:

python
borrow()

Print:

text
Book borrowed

Magazine

Extra attribute:

  • issue_number

Method:

python
borrow()

Print:

text
Magazine borrowed

Step 3: Create Objects

Create:

python
book1 = Book("Python Basics", 2024, "John Smith")
mag1 = Magazine("Tech Monthly", 2025, 12)

Step 4: Show Information

Call:

  • show_info()
  • borrow()

Expected output:

text
Python Basics 2024
Book borrowed
Tech Monthly 2025
Magazine borrowed

Step 5: Use Polymorphism

Create a list:

python
items = [book1, mag1]

Use a loop and call:

python
item.borrow()

Expected output:

text
Book borrowed
Magazine borrowed

Step 6: Add Encapsulation

Create a protected attribute:

python
_status

Start with:

text
Available

When borrowed, change it to:

text
Borrowed

Create method:

python
show_status()

Full Example Run

text
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.