Library Management System
Library Management System
Library
management
system
Presented by,
CO-FY
Om Appasaheb Mandavgad (Roll No: 25)
Aditya Ramkrishna Marathe (Roll No: 26)
Tejas Vilas Mhaske (Roll No: 27)
Yash Rajesh Mule (Roll No: 28)
Guided by,
Prof. Pande A. S.
Introduction
In today's digital age, efficient management of resources
is a crucial aspect of any system, especially in libraries
where books and users need to be tracked seamlessly. The
Library Management System (LMS) is designed to simplify
the process of managing a library's operations, including the
borrowing and returning of books, tracking users, and
maintaining an organized catalog. This project report
outlines the development of a Library Management System
using C++, one of the most popular programming languages
known for its efficiency and object-oriented capabilities.
The project is aimed at automating library operations,
providing an easy-to-use interface for both administrators
and users. The system enables users to search for available
books, borrow or return them, while administrators can
add, remove, or update book records as well as manage user
information. By implementing this project in C++, we ensure
that the system runs efficiently and provides quick
responses, even when handling large datasets.
This report will cover various aspects of the project,
including:
Class Structure
1. Book Class
Attributes:
o id: Unique identifier for each book.
o title: Title of the book.
o author: Author of the book.
o isIssued: Boolean flag to indicate whether the book is
currently issued or available.
Methods:
o addBook(): Initializes book attributes.
o displayBook(): Displays book details.
2. User Class
Attributes:
o id: Unique identifier for each user.
o name: Name of the user.
Methods:
o addUser(): Initializes user attributes.
o displayUser(): Displays user details.
3. Library Class
Attributes:
o books[MAX_BOOKS]: Array to store book objects.
o users[MAX_USERS]: Array to store user objects.
o bookCount: Counter to track the number of books.
o userCount: Counter to track the number of users.
Methods:
o addBook(): Adds a new book to the library.
o addUser(): Adds a new user to the library.
o searchBookByTitle(): Searches for a book by its title.
o issueBook(): Issues a book to a user.
o returnBook(): Processes the return of a book.
o displayAllBooks(): Displays all books in the library.
o displayAllUsers(): Displays all users registered in the
library.
Function Flow
1. User Interaction:
o The user navigates a menu-driven interface, selecting
options to manage books and users.
2. Adding Books and Users:
o When a book or user is added, the respective class method
(addBook or addUser) is called, initializing the object's
attributes and updating the count.
3. Searching for Books:
o The user can search for a book by title, which triggers the
searchBookByTitle method in the Library class to check
the array of books.
4. Issuing and Returning Books:
o When a book is issued or returned, the issueBook or
returnBook method is called, checking the book's current
status and updating the isIssued attribute accordingly.
5. Displaying Records:
o The displayAllBooks and displayAllUsers methods provide
a complete view of the library's inventory and user base.
Class Diagram
Book User
id: int id: int
title: string name: string
isIssued: bool addUser()
displayUser()
addBook()
displayBook()
Library
books[MAX_BOOKS]
users[MAX_USERS]
bookCount: int
userCount: int
addBook()
addUser()
searchBookByTitle()
issueBook()
returnBook()
displayAllBooks()
displayAllUsers()
Implementation
Key Features
1. Book Management
2. User Management
o The system allows for issuing books to users and keeping track
of which user has borrowed a specific book. A book's status is
updated accordingly when it is issued or returned.
4. Data Integrity
Data Structures
1. Book Class
2. User Class
3. Library Class
Algorithms
1. Adding Books and Users
o For issuing a book, the system searches for the book by its ID
in the books array, checks if it is available, and changes its
status to issued.
o For returning a book, the system checks if the book is issued
and changes its status back to available.
o Time Complexity: O(n), where n is the number of books. This
is because the system performs a linear search for the book by
its ID.
4. Displaying All Books and Users
Book() {
id = 0;
strcpy(title, "Unknown");
strcpy(author, "Unknown");
isIssued = false;
}
void displayBook() {
cout << "Book ID: " << id << ", Title: " << title << ", Author: " <<
author;
if (isIssued)
cout << " [Issued]" << endl;
else
cout << " [Available]" << endl;
}
};
// User class definition
class User {
public:
int id;
char name[100];
User() {
id = 0;
strcpy(name, "Unknown");
}
void displayUser() {
cout << "User ID: " << id << ", Name: " << name << endl;
}
};
public:
Library() {
bookCount = 0;
userCount = 0;
}
// Issue a book
void issueBook(int bookId) {
for (int i = 0; i < bookCount; i++) {
if (books[i].id == bookId) {
if (!books[i].isIssued) {
books[i].isIssued = true;
cout << "Book issued successfully!" << endl;
} else {
cout << "Book is already issued!" << endl;
}
return;
}
}
cout << "Book not found!" << endl;
}
// Return a book
void returnBook(int bookId) {
for (int i = 0; i < bookCount; i++) {
if (books[i].id == bookId) {
if (books[i].isIssued) {
books[i].isIssued = false;
cout << "Book returned successfully!" << endl;
} else {
cout << "Book was not issued!" << endl;
}
return;
}
}
cout << "Book not found!" << endl;
}
// Main function
int main() {
Library library;
int choice, bookId, userId;
char bookTitle[100], bookAuthor[100], userName[100];
while (true) {
cout << "\n--- Library Management System ---\n";
cout << "1. Add Book\n";
cout << "2. Add User\n";
cout << "3. Search Book by Title\n";
cout << "4. Issue Book\n";
cout << "5. Return Book\n";
cout << "6. Display All Books\n";
cout << "7. Display All Users\n";
cout << "8. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "Enter Book ID: ";
cin >> bookId;
cin.ignore(); // to ignore leftover newline from previous
input
cout << "Enter Book Title: ";
cin.getline(bookTitle, 100);
cout << "Enter Book Author: ";
cin.getline(bookAuthor, 100);
library.addBook(bookId, bookTitle, bookAuthor);
break;
case 2:
cout << "Enter User ID: ";
cin >> userId;
cin.ignore();
cout << "Enter User Name: ";
cin.getline(userName, 100);
library.addUser(userId, userName);
Break;
Case 3:
Court << "Enter Book Title to Search: “
cin.ignore();
cin.getline(bookTitle, 100);
library.searchBookByTitle(bookTitle);
break;
case 4:
cout << "Enter Book ID to Issue: ";
cin >> bookId;
library.issueBook(bookId);
break;
case 5:
cout << "Enter Book ID to Return: ";
cin >> bookId;
library.returnBook(bookId);
break;
case 6:
library.displayAllBooks();
break;
case 7:
library.displayAllUsers();
break;
case 8:
cout << "Exiting the program..." << endl;
return 0;
default:
cout << "Invalid choice, please try again." << endl;
}
}
return 0;
}
Output
1. Main Menu
2. Adding a Book
3. Adding a User
When option 6 is selected, the system displays the list of books currently
in the library:
When option 7 is selected, the system displays the list of all users:
The user selects option 3 to search for a book by its title. For example,
searching for "The Great Gatsby":
7. Issuing a Book
The user selects option 4 to issue a book to a user. After entering the
book ID, the system updates the book’s status:
8. Returning a Book
Future Scope: