Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this homework assignment, you are supposed to implement a library that contains multiple books. In this library, for each book, you will store a

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this homework assignment, you are supposed to implement a library that contains multiple books. In this library, for each book, you will store a record, in which you keep 1. The book title (string), 2. The name of its publishing house (string), 3. Its publishing year (integer), and 4. Its author list, in which you keep the names of its coauthor(s). The name of each coauthor must be considered as one string containing the first and last name of that author. Thus, this will be a list of strings. The user will add/remove books to/from the library. However, once a book is added to the library; the user can only add a coauthor(s) to the book, as explained below, but cannot edit the other details of this book (i.e., cannot change its title, publishing house, or publishing year). Thus, in your implementation: - You MUST keep the coauthor(s) of a book in a list. - You MUST keep a book as a tuple. Each tuple should contain at least four items: book title, publishing house, publishing year, and author list. - You MUST keep a library as a list of books (i.e., a list of book tuples). Your implementation must have at least six functions with the headers specified below. The details of these functions are explained below. def add_book(library, book_title, publishing_house, publishing_year) def remove_book(library, book_title) : def add_coauthor(iibrary, book_title, author_namo) : def display_all_books (1ibrary) : def show_book(1ibrary, book_title): def find_books (1ibrary, author_name): DD A BOOK This function adds a book to the library. The book title, the publishing house, and the publishing year are specified as parameters. In this function, the author list is not specified; the coauthor(s) that wrote this book will be added later. Thus, the author list should be set to an empty list by default. In this library, the book titles are unique. They are also case insensitive; that is, "Computer Vision" and "COMPuter viSion" should be considered as the same. Thus, if the user attempts to add a book with an already existing title, the function does not add the book to the library and displays a warning message. Otherwise, it performs the action. See the example test program and its corresponding output given below to understand how this function should work and the format of the warning message. REMOVE A BOOK This function removes a book from the library. The book title is specified as a parameter. If there is no book with the specified title, the function does not remove any book from the library and displays a warning message. Otherwise, it performs the action. Remember that all book titles are unique and case insensitive. See the example test program and its corresponding output given below to understand how this function should work and the format of the warning message. This function adds a coauthor to the author list of a book. The book title and the author's name are specified as parameters. If there is no book with the specified title, the function does not add the author to the book and displays a warning message. Otherwise, it performs the action. Remember that all book titles are unique and case insensitive. For the sake of simplicity, you may assume that a book may have multiple coauthors of the same name. Thus, you do not need to perform an additional check on whether the specified coauthor has already been added to the author list of this book. See the example test program and its corresponding output given below to understand how this function should work and the format of the warning message. DISPLAY ALL BOOKS This function lists all books already found in the library. If there are no books in the library, this function displays --EMPTY LIBRARY-- See the output example of the test program given below to understand the format. SHOW A BOOK This function displays all information about a book whose title is specified as a parameter. If the book with the specified title does not exist in the library, the function displays a warning message. Remember that all book titles are unique and case insensitive. See the example test program and its corresponding output given below to understand how this function should work and the format of the warning message. Note that the output is slightly different when the author list is empty, when it contains a single author, and when it contains multiple coauthors. Please check the examples below and implement your function accordingly. FIND BOOKS This function returns a list of the titles of all books written by an author. The author's name is specified as a parameter. If there is no book written by the given author, the function returns an empty list. See the example test program to understand how this function should work. Also sce the additional statements below to see how the output of this function can be used

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago