#K83017. Library Management System
Library Management System
Library Management System
You are required to implement a simple library management system that supports three commands:
- ADD: Adds a book to the library. The command is in the format
ADD title, author, year
. If a book with the same title already exists, update its information. - QUERY: Queries for a book by its title. The command is in the format
QUERY title
. If the book is found, output its author and year separated by a space; otherwise, printBook not found
. - DELETE: Deletes a book from the library. The command is in the format
DELETE title
. If the book exists, remove it and outputBook deleted
; otherwise, outputBook not found
.
The program reads commands from standard input (stdin) and prints the output to standard output (stdout). Note that only the QUERY
and DELETE
commands produce output.
You may assume that the year is an integer. There is no need to handle any malformed input.
There are no mathematical formulas in this problem; however, if needed, formulas must be formatted in LaTeX (e.g. \( ax^2+bx+c=0 \)).
inputFormat
The first line contains an integer N
which represents the number of commands.
Each of the following N
lines contains one command, which can be one of the following three types:
ADD title, author, year
QUERY title
DELETE title
There is a single space between the command and its parameters.
outputFormat
For each QUERY
or DELETE
command, output the corresponding result on a new line:
- For
QUERY
: If the book exists, outputauthor year
(separated by a space), otherwise outputBook not found
. - For
DELETE
: If the book is found and deleted, outputBook deleted
, otherwise outputBook not found
.
2
ADD The_Hobbit, J.R.R._Tolkien, 1937
QUERY The_Hobbit
J.R.R._Tolkien 1937