#C12604. Library Management System
Library Management System
Library Management System
In this problem, you are required to implement a simple library management system. The system tracks books and users, supporting operations such as adding/removing books, registering/removing users, checking out books, returning books, and viewing available books and borrowed books by a user.
You will receive commands from standard input. Each command is one of the following:
• add_book title author copies — Add a new book or increase copies if it already exists.
• remove_book title — Remove a book from the system.
• register_user user_id name — Register a new user.
• remove_user user_id — Remove an existing user.
• checkout_book user_id title — Allow a user to check out a book.
• return_book user_id title — Allow a user to return a book.
• view_available_books — Display all books with at least one available copy.
• view_user_borrowed_books user_id — Display all books borrowed by the specified user.
The output for view commands must be printed to standard output as described below. All formulas or constraints are displayed in (LaTeX)
format when applicable.
inputFormat
The input begins with an integer (T) (1 ≤ (T) ≤ 1000) representing the number of commands. Each of the next (T) lines contains a command and its parameters separated by spaces. All operations are guaranteed to be valid.
outputFormat
For commands that require output, produce the following:
• view_available_books: For each available book (i.e. with copies > 0), print a line in the format:
(title) (author) (copies)
sorted in lexicographical order of (title). If no books are available, print None.
• view_user_borrowed_books: Print a single line listing the titles borrowed by the user separated by a single space, or print None if the user has not borrowed any books.## sample
8
add_book Book1 Author1 3
register_user user1 John
checkout_book user1 Book1
view_available_books
view_user_borrowed_books user1
return_book user1 Book1
view_available_books
view_user_borrowed_books user1
Book1 Author1 2
Book1
Book1 Author1 3
None
</p>