Hands typing code on a laptop
Programming

Lab 14 · Python OOP Project Lab: Library Management System

Hands-on Lab 143 min readLevel: 🔴 Tough · Advanced100% FreeBy Tahmeer Tech

🎯 Objective

Use OOP for a real system design: model entities as classes with behaviour, and keep the system state consistent across operations.

🧩 Skills You Will Practice

  • Class design and encapsulation
  • Object relationships
  • Menu-driven program structure
  • Edge-case handling

🧰 What You Need

  • Python 3
  • VS Code
  • Files: library.py (single file is fine)
  • A class diagram sketched on paper before coding

📋 Step-by-Step Tasks

  1. Sketch the design: Book (title, author, copies, issued count), Member (name, member_id, borrowed list), Library (catalogue, members, issue/return methods). Decide what each class owns before writing code.
  2. Implement Book and Member with __init__ and a clean __str__ or describe method. Test by creating 3 books and 2 members and printing them.
  3. Implement Library.add_book and register_member, storing objects in lists or dictionaries keyed by ID. Print a catalogue view that shows available copies (copies minus issued).
  4. Implement issue_book(member_id, book_title): check the member exists, check a copy is available, record the loan on both the book and the member. Every check that fails must print a clear reason, not crash.
  5. Implement return_book with the reverse updates, and a member statement that lists everything a member currently holds.
  6. Build the console menu loop: 1 Add book, 2 Register member, 3 Issue, 4 Return, 5 Catalogue, 6 Member statement, 0 Exit. Validate menu input so letters and bad numbers never crash the system.
  7. Run a scripted test scenario: add 4 books, register 2 members, issue the last copy twice (second must be refused), return one, and verify the catalogue numbers at every step. Save the test output.

✅ Expected Result / Deliverable

A working library.py with 3 classes, a validated menu, a refused over-issue test, and catalogue counts that stay correct through issue/return — plus your original class diagram.

⚠️ Common Mistakes

  • Storing all data in global lists while classes do nothing (OOP in name only)
  • Updating the book count but forgetting the member record (or the reverse)
  • Crashing on bad menu input
Safety, Ethics & Pro Tip

Invent all members and books data. A library system is a design exercise — never enter real student, library or ID records into a practice program.