#C14184. Inventory Management System
Inventory Management System
Inventory Management System
You are required to implement an Inventory Management System that supports the following operations:
- ADD: Adds a new item with a given name and quantity. The item name must be a non-empty string and the quantity must be a positive integer. Upon adding, the system records a fixed timestamp \(2023\text{-}01\text{-}01\ 00:00:00\) as the last updated date.
- UPDATE: Updates the quantity of an existing item and resets its last updated date (to the fixed timestamp).
- SEARCH: Searches for an item (case-insensitive) and prints its details in the format:
Name: item, Quantity: quantity, Last Updated: timestamp
. - REPORT: Generates a report of all items in the order they were added. Each item is printed on a separate line in the same format as the search output.
If an operation is attempted with invalid parameters (for example, an empty name, non-positive quantity, or updating/searching a non-existent item), your program should print the appropriate error message as described in the operation definitions.
inputFormat
The input consists of several lines, each containing a command. The commands can be one of the following:
ADD <name> <quantity>
UPDATE <name> <quantity>
SEARCH <name>
REPORT
The commands should be processed sequentially until end-of-file. All outputs must be printed to standard output. Note that the fixed timestamp used for every update is 2023-01-01 00:00:00, and any formulas in the statement are written in \( \LaTeX \) format.
outputFormat
For every SEARCH
command, print one line with the details of the requested item in the following format:
Name: {name}, Quantity: {quantity}, Last Updated: 2023-01-01 00:00:00
For the REPORT
command, print the details of all items (each on a new line) in the order they were added, using the same format. For other commands (ADD
and UPDATE
), if the operation is successful, do not print any output; if there is an error (e.g. invalid input or item not found), print the error message.
ADD Apple 10
SEARCH Apple
Name: Apple, Quantity: 10, Last Updated: 2023-01-01 00:00:00
</p>