This project is a fully functional Library Management System implemented in C++, allowing for efficient management of library operations. The system provides users with features to add, search, borrow, return, delete, and display books in the library. It also supports managing waitlists for books that are unavailable.
The library system utilizes linked lists for book storage, providing dynamic and efficient memory management.
- Add Book: Add new books to the library, specifying ID, title, and author.
- Search Book: Search for books by ID or title and view their details.
- Borrow Book: Borrow books if available, or be added to a waitlist for the book.
- Return Book: Return borrowed books and notify the next user in the waitlist, if applicable.
- Delete Book: Remove books from the library using ID or title.
- Display Books: View all books currently in the library, along with their availability status.
- Manage Waitlists: Tracks users waiting for unavailable books and notifies them when the book becomes available.
- Dynamic Memory Allocation: Ensures efficient memory usage by dynamically creating and deleting book and waitlist nodes.
Upon program initialization, the library contains a collection of popular books, such as:
- The Great Gatsby by F. Scott Fitzgerald
- 1984 by George Orwell
- To Kill a Mockingbird by Harper Lee
- User Registration: Register users with personal details.
- Book Sorting: Implement sorting of books by title, author, or ID.
- Enhanced User Interface: Provide a more user-friendly experience with graphical options.
- Persistent Storage: Save library data to a file for long-term storage and load it during program startup.
- Linked Lists: Dynamically store books and their attributes.
- Custom Nodes: Manage waitlists for unavailable books using a separate linked list for each book.
- C++ compiler (e.g., GCC, Clang, or Visual Studio).
- Basic knowledge of compiling and running C++ programs.
-
Clone or download the repository.
-
Open a terminal or command prompt.
-
Navigate to the project directory.
-
Compile the code using the following command:
g++ -o LibraryManagementSystem main.cpp
-
Run the program:
./LibraryManagementSystem
The program provides an interactive menu to perform various actions:
- Add a new book: Specify ID, title, and author to add books.
- Display all available books: View the entire catalog and availability.
- Borrow a book: Enter the book ID and user ID to borrow books or join a waitlist.
- Return a book: Return a borrowed book and notify the next user in the waitlist.
- Search for a book: Search by title or ID.
- Delete a book: Remove books from the library.
- Exit: Exit the program.
- Add a book:
Enter book ID: 201 Enter book title: The Hobbit Enter book author: J.R.R. Tolkien
- Borrow a book:
Enter book ID to borrow: 101 Enter user ID: 1
- Return a book:
Enter book ID to return: 101
The implementation includes:
struct Book
: Represents a book with ID, title, author, availability status, and waitlist pointer.struct WaitingNode
: Represents a user waiting for a book.- Key Functions:
addBook()
: Adds a new book.searchBookByIdOrTitle()
: Searches for a book.deleteBook()
: Deletes a book from the library.borrowBook()
: Borrows a book or joins the waitlist if unavailable.returnBook()
: Processes a book return and notifies waitlisted users.displayBooks()
: Displays all books in the library.
Contributions to this project are welcome! You can:
- Add new features.
- Enhance the user interface.
- Optimize the current functionality.
This project is open-source and available under the MIT License.