Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve in python code Q2: You are required to design a system for a library to keep track of the available books in the library

solve in python code image text in transcribed
image text in transcribed
Q2: You are required to design a system for a library to keep track of the available books in the library and their customers. The description of the classes as follows: (NOTE: All attributes and methods are public) 1. A class Person which has the following attributes and methods: a. ID - a unique integer b. name - string c. A constructor that initializes the person's name and set its ID. d. An _str_ method that returns the ID and name as string. 2. A class Customer which is also a Person, in addition to the Person attributes it has the following attributes: a. MEMBERSHIPS - a tuple class attribute with the following values "PLATENIUM, SILVER, or GOLD" b. membership - a string that can be only one of the MEMBERSHIPS element c. A constructor that initializes the customer membership and ID and name. d. An_str_method that make a string of the ID and name (by calling the class Person__str_) and membership and then returns it. 3. A class Book which has the following attributes and methods: a. SN: Book serial number - unique integer b. Book title - string c. Book author - string d. Available: Boolean variable that indicate if the book is available or not e. A Constructor that initializes the book title and author. It should also set the book serial number and set available to True. f. An_str_method that make a string of all the book information and then returns it. 4. A class Library which has the following attributes and methods: a. name - a string representing the name of the library b. books - a list of all books in the library c. borrowed books - a dictionary of the books borrowed. The key should be the book serial number and the value should be the customer ID. d. customers - a list of library customers e. A constructor that initializes the name of the library and creates an empty list of books, an empty list of customers and an empty dictionary of borrowed books. f. add_customer(self, name, membership): add a new customer to the list of customers g. add_book(self, title, author): add a new book to the list of books h. borrow_book(self, book_sn, customer_id): add a new entry to borrowed_books dictionary, the key is the book_sn and the value is customer_id i. get_available_books(self): returns a list of available books j. find_customer_with_membership(self, membership): returns a list of customers with the passed membership type k. is_valid_book_sn(self, sn): check if the passed serial number is valid or not 1. is_valid_customer_id(self, id):: check if the passed customer is valid or not You should design your code in a way that can handle any bad input from the user without crashing (Exception handling). The explained methods should be enough, however, if you need to add more methods or functions, you can do so. Make sure to add comments explaining each function. Write a test code. Create an object (instance) of type Library with the name that you choose for your library. Then, print a menu that allow users to add a customer, add a book, borrow a book, or search for customers with specific membership. If the user chose to borrow a book, then only print the books that are available. Make sure to change the book availability to False if a user borrowed it. If all the books are borrowed, then, print "Sorry, there are no available books to borrow". Refer to the sample output. Note: this is just a sample output, your code should handle any possible input even if it is not illustrated in the sample output

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

2. How much time should be allocated to the focus group?

Answered: 1 week ago

Question

1. Where will you recommend that she hold the focus group?

Answered: 1 week ago