Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Library class with the following details: Instance variables: books lis

ID: 3575989 • Letter: C

Question

Create a Library class with the following details: Instance variables: books list of Book objects patrons list of patron objects Methods: init (self, books None, patrons None) constructor: instantiates all instance variables. When no list of books or patrons is supplied, this creates an empty list. str (self) returns a string representation of the library. It is the string Library books those items string cpatrons with ebooks and patrons replaced by the list representation of representations. Look at the sample run and test cases for larger repr (self) returns the same string representation of a library as str admit patron (self, patron) adds a to (end of the patrons list); they may now check out books. Patron the library o Returns None. o Raises a DuplicateIdError if there's already a patron with that id# patron by id self, patron id) searches for a patron with matching id#, and returns it. This method might be helpful in implementing other methods. o Returns a reference to a Patron. o Raises a MissingIdError if the patron wasn't found. book by id self, book-id) Returns a reference to the indicated book when present Don't worry about multiple matches. o Returns a reference to a Book o Raises a Missing IdError if no book with that id is found. book by title (self, title) Returns a reference to the indicated book present. Don't wo about multiple matches. when o Returns a reference to a Book

Explanation / Answer

Library(['{Id: 2,title: harry potter}', '{Id: 3,title: The Notebook}', '{Id: 1,title: The Notebook}'],['{Id: 4,borroweds: []}', '{Id: 2,borroweds: []}'])

Library(['{Id: 2,title: harry potter}'],['{Id: 4,borroweds: []}', "{Id: 2,borroweds: ['{Id: 1,title: The Notebook}', '{Id: 3,title: The Notebook}']}"])
Library(['{Id: 2,title: harry potter}', '{Id: 3,title: The Notebook}'],['{Id: 4,borroweds: []}', "{Id: 2,borroweds: ['{Id: 1,title: The Notebook}']}"])