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 Object-Oriented Programming (OOP) principles in Python. In the system, you will implement the concept of OOP, encapsulation, and how different classes can haveHAS-Arelationship between them.Read the description below to understand the classes and their methods and attributes.ClassBookAttributestitle (string),author (string),genre (string),available (boolean),borrower(None if no one borrowed the book; else object of LibraryMember)Methodsset_title(title),get_title(),set_author(author),get_author(),set_genre(genre),get_genre(),set_availability(),get_availability(),set_borrower(),get_borrower(),display_info()ClassLibraryMemberAttributesmember_id(string), name(string), borrowed_books(list of Book objects)Methodsset_member_id(member_id),get_member_id(),set_name(name),get_name(),borrow_book(book), return_book(book), display_borrowed_books()ClassLibraryAttributesbooks_available (list of Book objects), library_members (list of LibraryMember objects)Methodsadd_book(book), add_library_member(member), display_book_list(), display_library_members()Scenario Explanation:In this scenario, we have three main classes:Book, LibraryMember, and Library. Let's see how encapsulation and"HAS-A"relationship are demonstrated:1. 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 set_availability() to control the availability status of a book instead of directly accessing its "available" attribute.2. "HAS-A" Relationship:- The Library class has two attributes, `books_available` and `library_members`, which are lists containing objects of the Book and LibraryMember classes, respectively. This demonstrates the"HAS-A"relationship between Library, Book, and LibraryMember classes.- Additionally, the LibraryMember class has an attribute `borrowed_books`, 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 and"HAS-A"relationship 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 :
book1= Book("Harry Potter an

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!