#C13589. Library Management System Simulation

    ID: 43143 Type: Default 1000ms 256MiB

Library Management System Simulation

Library Management System Simulation

You are required to simulate a simple library management system. The system consists of four main entities: (\textbf{Book}), (\textbf{Member}), (\textbf{Librarian}), and (\textbf{Library}). The librarian can add or remove books and members from the library. Members can borrow available books and return them later. The library supports operations such as searching for a book by title, listing all available books, listing all borrowed books, and listing the books borrowed by a specific member. Your task is to process a sequence of commands (read from standard input) and output the corresponding results (to standard output).

inputFormat

The first line contains an integer (N) (the number of commands). Each of the following (N) lines contains a command. Commands can be one of the following:

  1. ADD_BOOK <book_id>: Add a new book to the library.
  2. REMOVE_BOOK <book_id>: Remove the book with the given id.
  3. ADD_MEMBER <member_id>: Add a new member to the library.
  4. REMOVE_MEMBER <member_id>: Remove the member with the given id.
  5. BORROW_BOOK <member_id> <book_id>: The member attempts to borrow the book.
  6. RETURN_BOOK <member_id> <book_id>: The member returns the book.
  7. SEARCH_BOOK : Search for a book by title (case-insensitive), and print matching book IDs separated by space or "None" if not found.
  8. LIST_AVAILABLE: List all available (not borrowed) book IDs separated by space or "None" if there is none.
  9. LIST_BORROWED: List all borrowed book IDs separated by space or "None" if there is none.
  10. LIST_BY_MEMBER <member_id>: List all book IDs borrowed by the member or "None" if there is none.

outputFormat

For each command, output a single line according to the command executed:

  • For ADD_BOOK, output "Book added".
  • For REMOVE_BOOK, output "Book removed".
  • For ADD_MEMBER, output "Member added".
  • For REMOVE_MEMBER, output "Member removed".
  • For BORROW_BOOK, output "Borrow successful" if the operation succeeded, otherwise "Borrow failed".
  • For RETURN_BOOK, output "Return successful" if the operation succeeded, otherwise "Return failed".
  • For SEARCH_BOOK, output the matching book IDs separated by a space, or "None" if no book is found.
  • For LIST_AVAILABLE and LIST_BORROWED, output the list of corresponding book IDs separated by a space, or "None" if the list is empty.
  • For LIST_BY_MEMBER, output the book IDs that the member has borrowed separated by a space, or "None" if none.## sample
8
ADD_BOOK Python_Programming John_Doe 1
ADD_MEMBER Alice 101
BORROW_BOOK 101 1
LIST_AVAILABLE
LIST_BORROWED
RETURN_BOOK 101 1
LIST_AVAILABLE
LIST_BORROWED
Book added

Member added Borrow successful None 1 Return successful 1 None

</p>