#C13262. Library Management System Simulation

    ID: 42781 Type: Default 1000ms 256MiB

Library Management System Simulation

Library Management System Simulation

You are tasked with implementing a simple simulation of a library management system. The system supports operations on two main entities: Book and Patron. Each Book has a title, an author, and an ISBN, and it is either available or checked out. Each Patron has a name and a card number, and can check out books.

The system supports the following operations:

  • ADD_BOOK <title>;<author>;<ISBN>: Add a new book to the library.
  • REMOVE_BOOK <ISBN>: Remove a book from the library using its ISBN.
  • ADD_PATRON <name>;<card_number>: Add a new patron to the library.
  • CHECKOUT <ISBN> <card_number>: Check out a book (if available) to a patron.
  • RETURN <ISBN> <card_number>: Return a checked out book to the library.

At the end of processing all commands, the program should output the current status of the library by printing all books (in order of addition) and all patrons with the number of books they have checked out. The string representation for the objects are defined as follows:

  • Book: {title} by {author} (ISBN: {ISBN}), Available: {available}
  • Patron: Patron: {name}, Card Number: {card_number}, Checked Out Books: {number_of_books}

Note: All formulas (if any) must be in LaTeX format (e.g. \(x^2+y^2=z^2\)).

inputFormat

The input is read from standard input. The first line contains an integer N, representing the number of operations. Each of the following N lines contains a command in one of the following formats:

  1. ADD_BOOK ;;
  2. REMOVE_BOOK
  3. ADD_PATRON ;<card_number>
  4. CHECKOUT <card_number>
  5. RETURN <card_number>

There will be no invalid commands and all operations will be such that they do not raise errors.

outputFormat

The program must output the final state of the library to standard output. The output consists of two sections:

  1. A list of books preceded by the line "Books:". Each book should be printed on its own line using the format: {title} by {author} (ISBN: {ISBN}), Available: {available}

  2. A list of patrons preceded by the line "Patrons:". Each patron should be printed on its own line using the format: Patron: {name}, Card Number: {card_number}, Checked Out Books: {number_of_books}

sample

6
ADD_BOOK 1984;George Orwell;1234567890
ADD_PATRON Alice;LIB001
CHECKOUT 1234567890 LIB001
RETURN 1234567890 LIB001
REMOVE_BOOK 1234567890
ADD_BOOK Brave New World;Aldous Huxley;0987654321
Books:

Brave New World by Aldous Huxley (ISBN: 0987654321), Available: True Patrons: Patron: Alice, Card Number: LIB001, Checked Out Books: 0

</p>