#C14160. Online Bookstore Inventory Management
Online Bookstore Inventory Management
Online Bookstore Inventory Management
You are required to implement an online bookstore inventory management system. The system supports several operations: adding a book to the inventory, updating its quantity, searching by title substring, searching by author name, checking the availability of a book (by its ISBN), and removing a book from the inventory.
The operations should be processed in order, reading input from standard input and outputting results to standard output. In particular, the commands that require output are:
- SEARCH_TITLE: Print the number of books whose title contains the given substring (case-insensitive).
- SEARCH_AUTHOR: Print the number of books by the given author (exact match).
- CHECK: Print "True" if the book's quantity is greater than 0; otherwise print "False".
All other commands do not print any output. The input starts with an integer n which signifies the number of commands, followed by n commands, one per line.
For operations:
- ADD title author isbn quantity: Adds the book with the given title, author, ISBN and quantity. If the book already exists (identified by ISBN), increase its quantity by the given amount.
- UPDATE isbn quantity: Updates the quantity of the book identified by the ISBN.
- SEARCH_TITLE substring: Searches for books whose title includes the substring (case-insensitive) and prints the count of books found.
- SEARCH_AUTHOR author: Searches for books by the exact author name and prints the count of books found.
- CHECK isbn: Checks if the book with the given ISBN is available (quantity > 0) and prints "True" or "False".
- REMOVE isbn: Removes the book from the inventory.
Your program must process all commands in order and produce the respective outputs as described above.
inputFormat
The first line contains an integer n (1 <= n <= 1000) representing the number of commands. Each of the following n lines contains a command. The commands are:
• ADD title author isbn quantity • UPDATE isbn quantity • SEARCH_TITLE substring • SEARCH_AUTHOR author • CHECK isbn • REMOVE isbn
Each field is separated by a single space. The title and author will not contain spaces.
outputFormat
For each SEARCH_TITLE, SEARCH_AUTHOR, and CHECK command, output the result on a separate line. Other commands do not produce any output.## sample
6
ADD TheGreatGatsby FScottFitzgerald 1234567890 10
ADD GatsbyReturns JohnDoe 0987654321 5
SEARCH_TITLE Gatsby
CHECK 1234567890
UPDATE 1234567890 0
CHECK 1234567890
2
True
False
</p>