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 bookid that represents the id of the book.
b One private instance data field named bookdetails which is a dictionary that will hold all the books in the shelf. It stores keyvalue pairs, where a key is a book id and value is an object of class Book.
c A constructor that initializes bookid to and creates an empty dictionary bookdetails.
d A method named addbook that accepts an object of type Book as a parameter, increments bookid by and inserts bookid and the book object as key and value in bookdetails.
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 gettitle and getauthor methods of Book class on the book object.
g A method named get bookid 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 if the book with given title is not found.
h A method named checkoutbook 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 ischeckedout 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 checkout method of the Book class on the book.
i A method named return booktoshelf that accepts id as a parameter. It checks if id is present in the keys of bookdetails. If not, it displays a string "Book with the given id not found". If yes, it invokes the returnbook method of the Book class on the book with the associated id
j A method named getinventory that prints every book in the dietionary bookdetails in the following format:
Id: Title: Book I Author: Author I Check Out Status: False
Where Book Author and False are the values of the variables id title, author, and checkedout, respectively. You will have to invoke the gettitle getauthor and ischeckedout methods of the Book class.
Programming in python please help
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
