Question: Create a file called Bookshelf, py and define a class named BookShelf to model a bookshelf in a library. The class contains: a . One

Create a file called Bookshelf, py and define a class named BookShelf to model a bookshelf in a library. The class contains:
a. One private instance int data field book_id that represents the id of the book.
b. One private instance data field named book_details which is a dictionary that will hold all the books in the shelf. It stores key-value pairs, where a key is a book id and value is an object of class Book.
c. A constructor that initializes book_id to 0 and creates an empty dictionary book_details.
d. A method named add_book () that accepts an object of type Book as a parameter, increments book_id by 1 and inserts book_id and the book object as key and value in book_details.
e. A method named remove book () that accepts an int id as a parameter. It checks if id is present in the keys of book details. If yes, it deletes the entry of the book with the given id. If not, it displays a string "Book with the given id not found".
f. A method named get title author () that accepts id as a parameter. It checks if id is present in the keys of book details. If yes, it returns title and author of the book with the associated id as a tuple. You will need to invoke the get_title() and get_author () methods of Book class on the book object.
g. A method named get book_id() that accepts title as a parameter. It returns the id for the given title. You will need to invoke the get_ title() method of Book class. The method returns -1 if the book with given title is not found.
h. A method named check_out_book() that accepts id as a parameter. It checks if id is present in the keys of book details. If not, it displays a string "Book with the given id not found". If yes, it checks if the book with the associated id is already checked out by invoking is_checked_out () method of the Book class. If the method returns true, display a string "Book not in the library.". If it is not checked out, invoke the check_out () method of the Book class on the book.
i. A method named return book_to_shelf() that accepts id as a parameter. It checks if id is present in the keys of book_details. If not, it displays a string "Book with the given id not found". If yes, it invokes the return_book() method of the Book class on the book with the associated id.
j. A method named get_inventory() that prints every book in the dietionary book_details in the following format:
Id: 1 Title: Book I Author: Author I Check Out Status: False
Where 1, Book1, Author1, and False are the values of the variables id, title, author, and checked_out, respectively. You will have to invoke the get_title(), get_author () and is_checked_out () methods of the Book class.
Programming in python please help
Create a file called Bookshelf, py and define a

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!