#C12836. Inventory Management System Simulation

    ID: 42307 Type: Default 1000ms 256MiB

Inventory Management System Simulation

Inventory Management System Simulation

You are required to simulate an inventory management system that supports the following operations on a store's product inventory:

  • add_product: Add a new product with an initial stock.
  • restock_product: Increase the stock of an existing product.
  • sell_product: Decrease the stock of an existing product.

The system also supports a case_sensitive flag. When set to True, product names are handled in a case-sensitive manner; otherwise product names are treated case-insensitively (i.e. converted to lowercase). If a sell operation would result in negative stock, the simulation should output an error message in the following format: \( \texttt{ is out of stock.} \)

Note: All numerical values are integers, and the operations are expected to be applied sequentially.

inputFormat

The input is given via standard input (stdin) and has the following format:

  1. An integer n representing the number of operations.
  2. n subsequent lines, each containing an operation in the format:
    command product_name quantity
    where command is one of add_product, restock_product, or sell_product, product_name is a string, and quantity is an integer.
  3. A final line containing either True or False indicating whether the operations should be handled in a case-sensitive manner.

outputFormat

If all operations are successful, output the final inventory status via standard output (stdout). Each line of the output should contain a product name and its corresponding stock, separated by a space. The products should be printed in lexicographical order.

If any sell operation would result in negative stock, output the error message (to stdout) in the format:

\( \texttt{ is out of stock.} \)

Note: In a case-insensitive mode, product names should be converted to lowercase in the output.

## sample
2
add_product Apple 10
sell_product Apple 5
False
apple 5

</p>