|
| 1 | +# Library Management System |
| 2 | + |
| 3 | +A library management system is an automation system used to manage a library and the different resource management required in it, such as cataloging books, allowing check-out and return of books, invoicing, user management, etc. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +Create a command-line application for the library management system with the following requirements: |
| 8 | + |
| 9 | +### Library Details |
| 10 | +- The library will have one or more copies of multiple books. |
| 11 | +- The library will have multiple racks, and each rack can contain at most one copy of any book. |
| 12 | +- Each book will have the following properties: |
| 13 | + - **Book ID** |
| 14 | + - **Title** |
| 15 | + - **Authors** |
| 16 | + - **Publishers** |
| 17 | + |
| 18 | +### Book Copies Details |
| 19 | +- There could be multiple copies of the same book. |
| 20 | +- Each book copy will have a unique ID. |
| 21 | +- Each book copy will be placed on a rack. |
| 22 | +- Each book copy can be borrowed by a user with a specific due date. |
| 23 | +- Every rack will have a unique rack number (numbered serially from 1 to n where n is the total number of racks). |
| 24 | + |
| 25 | +### User Details |
| 26 | +- User details include **User ID** and **Name**. |
| 27 | +- A user can borrow a maximum of 5 books. |
| 28 | + |
| 29 | +### Functionalities |
| 30 | +The library management system can perform the following functions: |
| 31 | + |
| 32 | +1. **Create a library.** |
| 33 | +2. **Add a book to the library.** |
| 34 | + - The book should be added to the first available rack. |
| 35 | +3. **Remove a book copy from the library.** |
| 36 | +4. **Allow a user to borrow a book copy given the book ID, user ID, and due date.** |
| 37 | + - The first available copy based on the rack number should be provided. |
| 38 | +5. **Allow a user to borrow a book copy given the book copy ID, user ID, and due date.** |
| 39 | +6. **Allow a user to return a book copy given the book copy ID.** |
| 40 | + - The book should be added to the first available rack. |
| 41 | +7. **Allow a user to print the book copy IDs of all the books borrowed by them.** |
| 42 | +8. **Allow a user to search for books using book properties (Book ID, Title, Author, Publisher).** |
| 43 | + - Searching should return details about all the book copies that match the search query. |
| 44 | + |
| 45 | +### Input/Output Format |
| 46 | + |
| 47 | +The code should strictly follow the input/output format and will be tested with provided test cases. |
| 48 | + |
| 49 | +#### Input Format |
| 50 | + |
| 51 | +Multiple lines, with each line containing a command. |
| 52 | + |
| 53 | +Possible commands: |
| 54 | + |
| 55 | +- `create_library <library_id> <no_of_racks>` |
| 56 | +- `add_book <book_id> <title> <comma_separated_authors> <comma_separated_publishers> <comma_separated_book_copy_ids>` |
| 57 | +- `remove_book_copy <book_copy_id>` |
| 58 | +- `borrow_book <book_id> <user_id> <due_date>` |
| 59 | +- `borrow_book_copy <book_copy_id> <user_id> <due_date>` |
| 60 | +- `return_book_copy <book_copy_id>` |
| 61 | +- `print_borrowed <user_id>` |
| 62 | +- `search <attribute> <attribute_value>` |
| 63 | + |
| 64 | +Possible values of attribute: `book_id`, `author`, `publisher`. |
| 65 | + |
| 66 | +Stop taking the input when you encounter the word `exit`. |
| 67 | + |
| 68 | +#### Output Format |
| 69 | + |
| 70 | +Print output based on the specific commands as mentioned below. |
| 71 | + |
| 72 | +**create_library** |
| 73 | + |
| 74 | +```plaintext |
| 75 | +Created library with <no_of_racks> racks |
| 76 | +``` |
| 77 | + |
| 78 | +**add_book** |
| 79 | + |
| 80 | +```plaintext |
| 81 | +Added Book to racks: <comma_separated_rack_nos> |
| 82 | +Rack not available |
| 83 | +``` |
| 84 | + |
| 85 | +**remove_book_copy** |
| 86 | + |
| 87 | +```plaintext |
| 88 | +Removed book copy: <book_copy_id> from rack: <rack_no> |
| 89 | +Invalid Book Copy ID |
| 90 | +``` |
| 91 | + |
| 92 | +**borrow_book** |
| 93 | + |
| 94 | +```plaintext |
| 95 | +Borrowed Book from rack: <rack_no> |
| 96 | +Invalid Book ID |
| 97 | +Not available |
| 98 | +Overlimit |
| 99 | +``` |
| 100 | + |
| 101 | +**borrow_book_copy** |
| 102 | + |
| 103 | +```plaintext |
| 104 | +Borrowed Book Copy from rack: <rack_no> |
| 105 | +Invalid Book Copy ID |
| 106 | +Overlimit |
| 107 | +``` |
| 108 | + |
| 109 | +**return_book_copy** |
| 110 | + |
| 111 | +```plaintext |
| 112 | +Returned book copy <book_copy_id> and added to rack: <rack_no> |
| 113 | +Invalid Book Copy ID |
| 114 | +``` |
| 115 | + |
| 116 | +**print_borrowed** |
| 117 | + |
| 118 | +```plaintext |
| 119 | +Book Copy: <book_copy_id> <due_date> |
| 120 | +``` |
| 121 | + |
| 122 | +**search** |
| 123 | + |
| 124 | +```plaintext |
| 125 | +Book Copy: <book_copy_id> <book_id> <title> <comma_separated_authors> <comma_separated_publishers> <rack_no> <borrowed_by_id> <due_date> |
| 126 | +``` |
| 127 | + |
| 128 | +### Examples |
| 129 | + |
| 130 | +#### Sample Input |
| 131 | + |
| 132 | +```plaintext |
| 133 | +create_library 10 |
| 134 | +add_book 1 book1 author1,author2 publisher1 book_copy1,book_copy2,book_copy3 |
| 135 | +add_book 2 book2 author2,author3 publisher2,publisher3 book_copy4,book_copy5,book_copy6,book_copy7,book_copy8,book_copy9,book_copy10 |
| 136 | +add_book 3 book3 author2 publisher2 book_copy11,book_copy12,book_copy13 |
| 137 | +search book_id 1 |
| 138 | +search book_id 3 |
| 139 | +search author_id author2 |
| 140 | +search author_id author3 |
| 141 | +remove_book_copy book_copy6 |
| 142 | +remove_book_copy book_copy13 |
| 143 | +add_book 3 book3 author2 publisher2 book_copy13 |
| 144 | +search book_id 2 |
| 145 | +print_borrowed user1 |
| 146 | +borrow_book 1 user1 2020-12-31 |
| 147 | +borrow_book 1 user1 2020-12-31 |
| 148 | +borrow_book 1 user1 2020-12-31 |
| 149 | +borrow_book 1 user1 2020-12-31 |
| 150 | +search book_id 1 |
| 151 | +search author_id author1 |
| 152 | +borrow_book 4 user1 2020-12-31 |
| 153 | +borrow_book 2 user1 2020-12-31 |
| 154 | +borrow_book 2 user1 2020-12-31 |
| 155 | +borrow_book 2 user1 2020-12-31 |
| 156 | +print_borrowed user1 |
| 157 | +return_book_copy book_copy1 |
| 158 | +return_book_copy book_copy2 |
| 159 | +borrow_book_copy book_copy1 |
| 160 | +borrow_book_copy book_copy1 |
| 161 | +borrow_book_copy book_copy2 |
| 162 | +borrow_book_copy book_copy10 |
| 163 | +print_borrowed user1 |
| 164 | +exit |
| 165 | +``` |
| 166 | + |
| 167 | +#### Expected Output |
| 168 | + |
| 169 | +```plaintext |
| 170 | +Created library with 10 racks |
| 171 | +Added Book to racks: 1,2,3 |
| 172 | +Added Book to racks: 4,5,6,7,8,9,10 |
| 173 | +Rack not available |
| 174 | +Book Copy: book_copy1 1 book1 author1,author2 publisher1 1 |
| 175 | +Book Copy: book_copy2 1 book1 author1,author2 publisher1 2 |
| 176 | +Book Copy: book_copy3 1 book1 author1,author2 publisher1 3 |
| 177 | +Book Copy: book_copy1 1 book1 author1,author2 publisher1 1 |
| 178 | +Book Copy: book_copy2 1 book1 author1,author2 publisher1 2 |
| 179 | +Book Copy: book_copy3 1 book1 author1,author2 publisher1 3 |
| 180 | +Book Copy: book_copy4 2 book2 author2,author3 publisher2,publisher3 4 |
| 181 | +Book Copy: book_copy5 2 book2 author2,author3 publisher2,publisher3 5 |
| 182 | +Book Copy: book_copy6 2 book2 author2,author3 publisher2,publisher3 6 |
| 183 | +Book Copy: book_copy7 2 book2 author2,author3 publisher2,publisher3 7 |
| 184 | +Book Copy: book_copy8 2 book2 author2,author3 publisher2,publisher3 8 |
| 185 | +Book Copy: book_copy9 2 book2 author2,author3 publisher2,publisher3 9 |
| 186 | +Book Copy: book_copy10 2 book2 author2,author3 publisher2,publisher3 10 |
| 187 | +Book Copy: book_copy4 2 book2 author2,author3 publisher2,publisher3 4 |
| 188 | +Book Copy: book_copy5 2 book2 author2,author3 publisher2,publisher3 5 |
| 189 | +Book Copy: book_copy6 2 book2 author2,author3 publisher2,publisher3 6 |
| 190 | +Book Copy: book_copy7 2 book2 author2,author3 publisher2,publisher3 7 |
| 191 | +Book Copy: book_copy8 2 book2 author2,author3 publisher2,publisher3 8 |
| 192 | +Book Copy: book_copy9 2 book2 author2,author3 publisher2,publisher3 9 |
| 193 | +Book Copy: book_copy10 2 book2 author2,author3 publisher2,publisher3 10 |
| 194 | +Removed book copy: book_copy6 from rack: 6 |
| 195 | +Invalid Book Copy ID |
| 196 | +Added Book to racks: 6 |
| 197 | +Book Copy: book_copy4 2 book2 author2,author3 publisher2,publisher3 4 |
| 198 | +Book Copy: book_copy5 2 book2 author2,author3 publisher2,publisher3 5 |
| 199 | +Book Copy: book_copy7 2 book2 author2,author3 publisher2,publisher3 7 |
| 200 | +Book Copy: book_copy8 2 book2 author2,author3 publisher2,publisher3 8 |
| 201 | +Book Copy: book_copy9 2 book2 author2,author3 publisher2,publisher3 9 |
| 202 | +Book Copy: book_copy10 2 book2 author2,author3 publisher2,publisher3 10 |
| 203 | +Borrowed Book from rack: 1 |
| 204 | +Borrowed Book from rack: 2 |
| 205 | +Borrowed Book from rack: 3 |
| 206 | +Not available |
| 207 | +Book Copy: book_copy1 1 book1 author1,author2 publisher1 -1 user1 2020-12-31 |
| 208 | +Book Copy: book_copy2 1 book1 author1,author2 publisher1 -1 user1 2020-12-31 |
| 209 | +Book Copy: book_copy3 1 book1 author1,author2 publisher1 -1 user1 2020-12-31 |
| 210 | +Book Copy: book_copy1 1 book1 author |
| 211 | +
|
| 212 | +1,author2 publisher1 -1 user1 2020-12-31 |
| 213 | +Book Copy: book_copy2 1 book1 author1,author2 publisher1 -1 user1 2020-12-31 |
| 214 | +Book Copy: book_copy3 1 book1 author1,author2 publisher1 -1 user1 2020-12-31 |
| 215 | +Invalid Book ID |
| 216 | +Borrowed Book from rack: 4 |
| 217 | +Borrowed Book from rack: 5 |
| 218 | +Overlimit |
| 219 | +Book Copy: book_copy1 2020-12-31 |
| 220 | +Book Copy: book_copy2 2020-12-31 |
| 221 | +Book Copy: book_copy3 2020-12-31 |
| 222 | +Book Copy: book_copy4 2020-12-31 |
| 223 | +Book Copy: book_copy5 2020-12-31 |
| 224 | +Returned book copy book_copy1 and added to rack: 1 |
| 225 | +Returned book copy book_copy2 and added to rack: 2 |
| 226 | +Borrowed Book from rack: 1 |
| 227 | +Invalid Book Copy ID |
| 228 | +Borrowed Book from rack: 2 |
| 229 | +Overlimit |
| 230 | +Book Copy: book_copy1 2020-12-31 |
| 231 | +Book Copy: book_copy2 2020-12-31 |
| 232 | +Book Copy: book_copy3 2020-12-31 |
| 233 | +Book Copy: book_copy4 2020-12-31 |
| 234 | +Book Copy: book_copy5 2020-12-31 |
| 235 | +``` |
| 236 | + |
| 237 | +### Expectations |
| 238 | + |
| 239 | +- **Functional and Demonstrable Code**: Ensure the code is working and can be demonstrated. |
| 240 | +- **Functionally Correct**: The code should perform all specified functionalities correctly. |
| 241 | +- **Modular and Readable Code**: Code should be broken into manageable functions and classes, and should be easy to read. |
| 242 | +- **Separation of Concerns**: Ensure the code adheres to the principle of separation of concerns. |
| 243 | +- **Maintainable Code**: The code should accommodate new requirements with minimal changes. |
| 244 | +- **Main Method**: Provide a main method for easy testing. |
| 245 | +- **Optional**: Write unit tests if possible. |
| 246 | +- **No GUI**: There's no need for a graphical user interface. |
| 247 | + |
| 248 | +### Optional Requirements |
| 249 | + |
| 250 | +- **Extensibility**: Allow for changing the number of books users can borrow. |
| 251 | +- **Additional Attributes**: Allow adding more attributes to the book and book search system. |
| 252 | +- **Thread Safety**: Make the system thread-safe to handle concurrent requests. |
| 253 | + |
| 254 | +--- |
| 255 | + |
| 256 | +This document provides a comprehensive outline of the library management system, its requirements, and expected functionality. The design should ensure modularity, readability, and maintainability, with considerations for future extensibility and thread safety. |
0 commit comments