Book and User Classes
Part of the Object Oriented Programming section of Coddy's Python journey. Lesson 56 of 64.
Challenge
EasyIn this challenge, you'll implement the Book class for a library management system using a multi-file structure with comprehensive test coverage.
Edit book.py to implement the Book class following the TODO comments. The implementation should:
- Initialize with title, author, and ISBN parameters
- Track availability status and borrower information
- Implement proper string representation
Try it yourself
from book import Book
# 1. Create a Book object
book = Book("1984", "George Orwell", "345678")
# 2. Check attributes
print(book.title) # Should print: 1984
print(book.author) # Should print: George Orwell
print(book.isbn) # Should print: 345678
print(book.available) # Should print: True
print(book.borrower) # Should print: None
# 3. Test __str__ when available
print(book) # Should print: 1984 by George Orwell (ISBN: 345678) - Available
# 4. Test __str__ when not available
book.available = False
print(book) # Should print: 1984 by George Orwell (ISBN: 345678) - Not AvailableAll 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