Question: You are tasked with designing a Library Management System following Object - Oriented Programming ( OOP ) principles in Python. In the system, you will
You are tasked with designing a Library Management System following ObjectOriented Programming OOP principles in Python. In the system, you will implement the concept of OOP, encapsulation, and how different classes can haveHASArelationship between them.Read the description below to understand the classes and their methods and attributes.ClassBookAttributestitle stringauthor stringgenre stringavailable booleanborrowerNone if no one borrowed the book; else object of LibraryMemberMethodssettitletitlegettitlesetauthorauthorgetauthorsetgenregenregetgenresetavailabilitygetavailabilitysetborrowergetborrowerdisplayinfoClassLibraryMemberAttributesmemberidstring namestring borrowedbookslist of Book objectsMethodssetmemberidmemberidgetmemberidsetnamenamegetnameborrowbookbook returnbookbook displayborrowedbooksClassLibraryAttributesbooksavailable list of Book objects librarymembers list of LibraryMember objectsMethodsaddbookbook addlibrarymembermember displaybooklist displaylibrarymembersScenario Explanation:In this scenario, we have three main classes:Book LibraryMember, and Library. Let's see how encapsulation andHASArelationship are demonstrated: Encapsulation: The attributes of each class are kept private and accessed through getter and setter methods. For example, the Book class has a method named setavailability to control the availability status of a book instead of directly accessing its "available" attribute "HASA Relationship: The Library class has two attributes, booksavailable and librarymembers which are lists containing objects of the Book and LibraryMember classes, respectively. This demonstrates theHASArelationship between Library, Book, and LibraryMember classes. Additionally, the LibraryMember class has an attribute borrowedbooks which is a list containing Book objects. This shows that each LibraryMemberHASmultiple Book objects that they have borrowed.Method Description:ClassBook:ClassLibraryMember:ClassLibrary:This system is a simple Library Management System with classes that showcase encapsulation andHASArelationship between classes. The classes work together to allow library members to borrow and return books, and the Library class manages the collection of books and library members.
Demo driver code and output :
book BookHarry Potter an
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
