#C14868. Book Catalog System
Book Catalog System
Book Catalog System
You are required to implement a book catalog system. The system supports adding, retrieving, and deleting books. Each book is characterized by a unique identifier (ID), a title, an author, and the publication year. The catalog can store at most books.
Operations that your program must support (via standard input) include:
1. ADD id title author year
– Add a new book with the specified attributes. If the catalog already contains books, then this command is to be ignored.
2. DELETE id
– Remove the book with the given id from the catalog.
3. GET id
– Retrieve the details of a book. If the book exists, output its details in the following format:
Book details: ID=id, Title=title, Author=author, Year=year
Otherwise, output Book not found
.
Please note that the title and author in the input will not contain whitespace (use underscore instead of space if necessary).
inputFormat
The input is read from standard input. The first line contains an integer denoting the number of commands. Each of the next lines contains one command. The command is one of the following three formats:
1. ADD id title author year
2. DELETE id
3. GET id
outputFormat
For each GET
command in the input, output a single line to standard output. The line should either be the details of the requested book formatted exactly as
Book details: ID=id, Title=title, Author=author, Year=year
or, if the book does not exist, the line should read Book not found
.## sample
6
ADD 1 To_Kill_a_Mockingbird Harper_Lee 1960
GET 1
DELETE 1
GET 1
ADD 2 1984 George_Orwell 1949
GET 2
Book details: ID=1, Title=To_Kill_a_Mockingbird, Author=Harper_Lee, Year=1960
Book not found
Book details: ID=2, Title=1984, Author=George_Orwell, Year=1949
</p>