Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python please Define a class named MyLibrary which represents a simple library system. The simple library system should allow people to borrow, return and search

image text in transcribedpython please

image text in transcribed
Define a class named MyLibrary which represents a simple library system. The simple library system should allow people to borrow, return and search for books in the collection. It also provides the functionalities such as displaying the list of available books and a list of on-loan books, etc. The MyLibrary class contains: A private data field named name that defines the name of a library. A private data field named _books_list that defines a list of the Book objects in the library. A constructor/initializer that takes a name and a filename as parameters (default of empty string). If the filename is not an empty string, the method should load all the books from a text file into the books list of the library system. Download the sample text files from here. o If the file does not exist, an error message is displayed as in the example below. o After loading all the books into the books list, the method should print the number of books loaded as in the example below. The show_all_books (self) method which prints out all the books in the collection as shown in the example below. Note: You can assume that the Book class is given. Keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks. For example: Test Result = library MyLibrary( 'MyLibrary', 'simple_books.txt') 5 books loaded. print() library.show_all_books () The Lord Of The Rings, QS12.03.001 (Available) The Hitchhiker's Guide To The Galaxy, QK12.04.002 (Available) The Dune Chronicles, QS12.02.003 (Available) A Song of Ice And Fire Series, QA12.04.004 (Available) The Foundation Trilogy, QS12.01.005 (Available) ERROR: The file 'input_file.txt' does not exist. library MyLibrary( 'MyLibrary','input_file.txt') library.show_all_books () QS12.03.001,The Lord Of The Rings QK12.04.002,The Hitchhiker's Guide To The Galaxy QS12.02.003,The Dune Chronicles QA12.04.004, A Song Of Ice And Fire Series QS12.01.005,The Foundation Trilogy

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions