Agam DSA Project
Agam DSA Project
on
Simple Library
Management System
Submitted By-
Name- Agam Singh
Program- B.Tech(Computer Science and
Engineering)
Lovely Professional University.
Phagwara
Source Code-
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
class Book {
public:
string title;
string author;
int id;
bool issued;
class Node {
public:
Book* book;
Node* next;
Node(Book* book)
{
this->book = book;
this->next = nullptr;
}
};
class LinkedList {
private:
Node* head;
public:
LinkedList()
{
head = nullptr;
}
void issueBook()
{
string title;
cout << "Enter book title to issue: ";
cin.ignore();
getline(cin, title);
int index = searchBook(title);
if (index != -1) {
Node* temp = getNodeAtIndex(index);
if (temp->book->issued) {
cout << "Book already issued." << endl;
}
else {
temp->book->issued = true;
cout << "Book issued successfully." << endl;
cout << "Book issued using stack." << endl;
}
}
else {
cout << "Book not found." << endl;
}
}
void returnBook()
{
string title;
cout << "Enter book title to return: ";
cin.ignore();
getline(cin, title);
i = 0;
j = 0;
k = left;
delete[] L;
delete[] R;
}
void listAllBooks()
{
if (head == nullptr) {
cout << "No books in the library." << endl;
return;
}
delete[] bookArray;
}
void deleteBook()
{
if (head == nullptr) {
cout << "No books in the library." << endl;
return;
}
string title;
cout << "Enter book title to delete: ";
cin.ignore();
getline(cin, title);
private:
Node* getNodeAtIndex(int index)
{
Node* temp = head;
for (int i = 0; i < index; i++) {
temp = temp->next;
}
return temp;
}
int getNodeCount()
{
int count = 0;
Node* temp = head;
while (temp != nullptr) {
count++;
temp = temp->next;
}
return count;
}
};
int main()
{
LinkedList library;
int choice;
do {
cout << "\nLibrary Management System\n";
cout << "1. Add Book\n";
cout << "2. Search Book\n";
cout << "3. Issue Book\n";
cout << "4. Return Book\n";
cout << "5. List All Books\n";
cout << "6. Delete Book\n";
cout << "0. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
string title, author;
int id;
return 0;
}
Output-