#K85507. Library System Management
Library System Management
Library System Management
You are required to implement a library system management program that processes operations related to borrowing, returning, and listing borrowed books. The system maintains records of books, authors, and members. Each member has an associated list of borrowed books. The operations are as follows:
- borrow: Add a book to the member's borrowed list if no other member has borrowed that same book. Formally, if the book's ISBN, denoted by \(isbn\), is not present in any member's borrowed books (i.e. \(isbn \notin \bigcup_{m \in Members} m.borrowed\_books\)), the operation is allowed.
- return: Remove the book (if present) from the member's borrowed books.
- list: List all books currently borrowed by the specified member.
The program should accept input from stdin
and print the result to stdout
. For borrow
and return
operations, print "Success" upon completion. For the list
operation, output the list of ISBNs separated by a space. If the member has no borrowed books, output "None".
inputFormat
The input is read from stdin
and has the following format:
B book_line_1 book_line_2 ... book_line_B A author_line_1 author_line_2 ... author_line_A M member_line_1 member_line_2 ... member_line_M operation member_id [isbn]
Explanation:
B
: Number of books.- Each
book_line
is in the format:isbn|title|author_id|category
. A
: Number of authors.- Each
author_line
is in the format:author_id|name
. M
: Number of members.- Each
member_line
is in the format:member_id|name|borrowed_books
. If the member does not have any borrowed books, the field will beNone
; otherwise, multiple ISBNs are separated by a comma. operation
: One ofborrow
,return
, orlist
.member_id
: The member performing the operation.- If
operation
isborrow
orreturn
, an additional line withisbn
is provided.
outputFormat
The output is printed to stdout
:
- If the operation is
borrow
orreturn
, print "Success". - If the operation is
list
, print the list of borrowed ISBNs separated by a space. If the list is empty, print "None".
2
978-3-16-148410-0|The Great Gatsby|1|fiction
978-1-56619-909-4|1984|2|dystopia
2
1|F. Scott Fitzgerald
2|George Orwell
2
A123|John Doe|None
B456|Jane Smith|None
borrow
A123
978-3-16-148410-0
Success