Project Overview
Part of the Object Oriented Programming section of Coddy's Python journey. Lesson 55 of 64.
Challenge
MediumIn this challenge, you'll implement the foundation for a Library Management System.
Edit library.py to implement the required classes following the TODO comments. The driver file contains extensive test scenarios that validate your implementation.
- Follow the TODO comments in
library.pyfor step-by-step guidance - Implement the
Libraryclass with proper initialization and string representation
Try it yourself
from library import Library
# Comprehensive test case handler
test_case = input()
if test_case == "basic_library_creation":
library_name = "Test Library"
library = Library(library_name)
print(library)
elif test_case == "library_attributes":
library = Library("Test Library")
print(f"Name: {library.name}")
print(f"Books: {len(library.books)}")
print(f"Users: {len(library.users)}")
elif test_case == "multiple_libraries":
library1 = Library("Library 1")
library2 = Library("Library 2")
print(library1)
print(library2)
elif test_case == "empty_name":
library = Library("")
print(library)
elif test_case == "special_characters":
library = Library("!@#$%^&*()")
print(library)
elif test_case == "very_long_name":
long_name = "A" * 100
library = Library(long_name)
print(library)
elif test_case == "add_books_users":
library = Library("Test Library")
library.books.extend(["Book1", "Book2", "Book3"])
library.users.extend(["User1", "User2"])
print(library)
elif test_case == "empty_lists":
library = Library("Test Library")
print(f"Books length: {len(library.books)}")
print(f"Users length: {len(library.users)}")
elif test_case == "type_validation":
library = Library(123)
print(library)All lessons in Object Oriented Programming
1Fundamentals of OOP
External FilesIntroduction to OOPClasses vs ObjectsThe self ParameterMethodsAttributesConstructor Method (__init__)Recap - Simple Calculator4Inheritance
Basic InheritanceThe super() FunctionMethod OverridingMultiple InheritanceMethod Resolution OrderRecap - Employee Hierarchy7Special Methods
Magic Methods IntroductionOperator OverloadingContainer Magic MethodsRecap - Custom List10Design Patterns Part 1
Intro to design patternSingleton PatternFactory PatternObserver PatternStrategy Pattern2Decorators
Introduction to DecoratorsProperty DecoratorStatic Method DecoratorClass Method Decorator5Polymorphism
Method Overriding RevisitedDuck TypingAbstract Classes and MethodsInterface DesignRecap - Shape Calculator8Advanced OOP Concepts
Composition vs InheritanceMixinsStatic and Class MethodsClass DecoratorsContext Managers3Class Properties
Instance vs Class VariablesProperty DecoratorsPrivate AttributesRecap - Bank Account Manager6Encapsulation
Public, Protected, Private MemAccess ModifiersInformation HidingProperty Decorators AdvancedRecap - Student Records System12Project: Library Management
Project OverviewBook and User ClassesBorrowing SystemSearch FunctionalityAdmin InterfaceTesting and IntegrationPractice on your own: Online Python compiler