#K35027. Library Book Catalog Management
Library Book Catalog Management
Library Book Catalog Management
You are required to implement a library book catalog system. The catalog supports adding, removing, and searching for books. Each book is identified by its ISBN, title, and author. All operations are case‐insensitive.
The system should support the following operations:
ADD ISBN|TITLE|AUTHOR
: Add a new book with the given ISBN, title, and author to the catalog.REMOVE ISBN
: Remove the book with the given ISBN from the catalog.SEARCH_TITLE TITLE
: Search for books whose title exactly matches TITLE (case-insensitive) and output each matching book in the formatISBN: TITLE by AUTHOR
.SEARCH_AUTHOR AUTHOR
: Search for books whose author exactly matches AUTHOR (case-insensitive) and output each matching book in the same format.
If a search yields no results, output a single line with Not Found
.
Note: The ISBN is unique for each book. For operations that do not produce output (ADD and REMOVE), nothing should be printed.
The input is provided via stdin and you should write the output to stdout.
For example, if we add a book with ISBN 978-1-56592-326-4, title Design Patterns and author Erich Gamma, then a search for Design Patterns or Erich Gamma should output:
\[ \texttt{978-1-56592-326-4: Design Patterns by Erich Gamma} \]inputFormat
The first line of the input contains an integer n indicating the number of commands. Each of the following n lines contains one command. The commands are as follows:
ADD ISBN|TITLE|AUTHOR
REMOVE ISBN
SEARCH_TITLE TITLE
SEARCH_AUTHOR AUTHOR
For the ADD
command, the ISBN, TITLE, and AUTHOR are separated by the pipe symbol |
. For search commands, the search string may contain spaces.
outputFormat
For each search command (SEARCH_TITLE
or SEARCH_AUTHOR
), output the matching books, each on a separate line, in the format ISBN: TITLE by AUTHOR
. If no matching books are found, output a single line with Not Found
. There should be no output for the ADD
or REMOVE
commands.
4
ADD 978-0-321-49686-5|The Mythical Man-Month|Frederick P. Brooks Jr.
ADD 978-1-56592-326-4|Design Patterns|Erich Gamma
SEARCH_TITLE Design Patterns
SEARCH_AUTHOR Erich Gamma
978-1-56592-326-4: Design Patterns by Erich Gamma
978-1-56592-326-4: Design Patterns by Erich Gamma
</p>