#K5076. Library Book Lending Management

    ID: 28936 Type: Default 1000ms 256MiB

Library Book Lending Management

Library Book Lending Management

You are required to implement a library management system that processes various operations related to book lending. The system should allow users to borrow books, return them, and query the status of books. It must enforce rules such as a borrowing period (in days) and a limit on the number of books a member can borrow.

The operations to be supported are:

  • BORROW: A member attempts to borrow a book. If the book is not currently borrowed and the member hasn’t reached their borrowing limit, the system should mark the book as borrowed and return the due date computed by adding the borrowing period to the borrow date. Otherwise, return an error message.
  • RETURN: A member returns a book. The system checks if the book was borrowed by that member and, if so, marks it as returned.
  • DUEDATE: Query the due date of a borrowed book. If the book isn’t borrowed, return the message "Book not borrowed".
  • BOOKS: List all ISBN numbers of books currently borrowed by a member. If none, output an empty line.
  • LENDING_INFO: Retrieve the member ID and due date for a given borrowed book. If the book is not borrowed, output "Book not borrowed".

All dates are in \texttt{YYYY-MM-DD} format.

inputFormat

The input is read from standard input and consists of:

  1. The first line contains three integers: borrowing_period (in days), borrowing_limit (maximum books a member can borrow) and q (the number of queries).
  2. The next q lines each contain a command. The commands can be one of the following:
    • BORROW isbn member_id date
    • RETURN isbn member_id date
    • DUEDATE isbn
    • BOOKS member_id
    • LENDING_INFO isbn

Process each command in order and output the result immediately on a new line.

outputFormat

For each query command, output the following:

  • BORROW: Output the due date if borrowing is successful; otherwise, output an error message: either "Book not available" (if the book is already borrowed) or "Member has exceeded borrowing limit".
  • RETURN: Output "Book returned successfully" if the return is valid; otherwise, output "Book not borrowed by member".
  • DUEDATE: Output the due date of the book if it is borrowed; otherwise, output "Book not borrowed".
  • BOOKS: Output a space‐separated list of ISBN numbers borrowed by the member. Output an empty line if none.
  • LENDING_INFO: Output the member id and due date separated by a space if the book is borrowed; otherwise, output "Book not borrowed".

Each output should be printed on a separate line corresponding to the command order.

## sample
14 7 7
BORROW 978-3-16-148410-0 member01 2023-01-01
BORROW 978-3-16-148410-0 member02 2023-01-01
DUEDATE 978-3-16-148410-0
BOOKS member01
RETURN 978-3-16-148410-0 member02 2023-01-10
RETURN 978-3-16-148410-0 member01 2023-01-10
DUEDATE 978-3-16-148410-0
2023-01-15

Book not available 2023-01-15 978-3-16-148410-0 Book not borrowed by member Book returned successfully Book not borrowed

</p>