#C9379. Book List Manager
Book List Manager
Book List Manager
You are given an initial list of books. Each book is defined by its title, author, and year of publication. You will then receive a series of commands to manage the list. The commands are in one of the following formats:
- add <title> by <author> published in <year>: Add a new book to the list.
- remove <title>: Remove the book with the specified title. If no such book exists, output
Book not found!
. - find <title>: Search for the book with the specified title. If found, output its details in the format Title: <title>, Author: <author>, Year: <year>; otherwise, output
Book not found!
.
The input and output are handled via stdin and stdout respectively.
inputFormat
The input begins with an integer N representing the number of initial books. The next N lines each contain the details of a book in the format:
title,author,year
Then, an integer M is given representing the number of commands. The following M lines each contain a command, which can be one of the following:
- add by published in
- remove
- find
Note that all commands and book details are read from standard input (stdin).
outputFormat
For every command that requires an output (i.e. the find
command or a failed remove
command), print the result on a new line to standard output (stdout).
For a find
command, if the book is found, print:
Title: <title>, Author: <author>, Year: <year>
If the book is not found or if a remove
command fails to find the book, print:
Book not found!
Commands that successfully add or remove a book produce no output.## sample
2
To Kill a Mockingbird,Harper Lee,1960
1984,George Orwell,1949
2
add Moby Dick by Herman Melville published in 1851
find Moby Dick
Title: Moby Dick, Author: Herman Melville, Year: 1851