0% found this document useful (0 votes)
9 views4 pages

Include

Uploaded by

ramshafatima752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Include

Uploaded by

ramshafatima752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <iostream>

#include <vector>
#include <string>
using namespace std;

struct section {
char sec;
section* nexts;
section_points* connection;
section() : sec('/0'), nexts(nullptr), connection(nullptr){}
};

struct section_points{
char next_section; // Next vertex
int distance; // Distnce of each edge
section_points* next_edge; // Next edge from vrtex section
section_points() : next_section('/0'), distance(0), next_edge(nullptr) {}
};

struct book {
string name;
int ISBN;
bool status;
book* nextb;
user* nextu;
char sect;
book() : ISBN(0), status(1), nextb(nullptr), nextu(nullptr), sect('/0') {}
};

struct user {
string name;
string degree;
int date_gain;
int date_return;
user* next;
user() : date_gain(0), date_return(0), next(nullptr) {}
};

class Library_System {
book* head_book;
section* head_section;
public:
Library_System() : head_book(nullptr), head_section(nullptr){}
void insert_book() {
cout << "Enter book details: " << endl;
if (head_book == nullptr) {
head_book = new book;
cout << "Name: " << endl;
cin >> head_book->name;;
cout << "ISBN: " << endl;
cin >> head_book->ISBN;
cout << "Enter Section: " << endl;
cin >> head_book->sect;
head_book->status = 1;
}
else if (head_book != nullptr) {
book* temp = head_book;
while (temp->nextb != nullptr) {
temp = temp->nextb;
}
temp->nextb = new book;
cout << "Name: " << endl;
cin >> temp->nextb->name;;
cout << "ISBN: " << endl;
cin >> temp->nextb->ISBN;
cout << "Section: " << endl;
cin >> temp->nextb->sect;
head_book->status = 1;
}
else
cout << "^_^" << endl;
}
void borrow() {
int i;
cout << "Enter ISBN : " << endl;
cin >> i;
book* temp = head_book;
while (temp->ISBN != i) {
temp = temp->nextb;
}
if (temp->status == 0) {
cout << "Book is not available" << endl;
}
else {
temp->nextu = new user;
cout << "Enter your details: " << endl;
cout << "Name: " << endl;
cin >> temp->nextu->name;;
cout << "Degree: " << endl;
cin >> temp->nextu->degree;
cout << "Date: mm/dd/yyyy" << endl;
cin >> temp->nextu->date_gain;
temp->status = 0;
}
}
void book_return() {
//User details will be saved for record, only book status will change
book* temp = head_book;
int i = 0;
cout << "Enter ISBN of book to return: " << endl;
cin >> i;
if (check(i) == 1) {
while (temp->ISBN != i) {
temp = temp->nextb;
}
temp->status = 0;
}
else
cout << "Wrong entry" << endl;
}
void query() {

}
// To check if a bokk exist or not
bool check(int i) {
book* temp = head_book;
while (temp->nextb != nullptr) {
temp = temp->nextb;
if (temp->ISBN == i) {
cout << "Book is available in directory" << endl;
return 1;
}
else
cout << "Processing" << endl;
}
cout << "Book is not available" << endl;
return 0;
}
void query() {
int i = 0, y = 0;
book* temp = head_book;
cout << "Enter ISBN of book you want the details: " << endl;
cin >> i;
if (check(i) == 1) {
cout << "Press 1 for Name \n Press 2 for Availability \n Press 3 to get user details"
<< endl;
cin >> y;
while (temp->ISBN != i) {
temp = temp->nextb;
}
switch (y) {
case 1:
cout << "Name: " << temp->ISBN << endl;
case 2:
cout << "Availability: " << temp->status << endl;
case 3:
cout << "User details: " << endl;
while (temp->nextu != nullptr) {
cout << "Name: " << temp->nextu->name <<endl;
cout << "Degree: " << temp->nextu->degree << endl;
cout << "Date Issued: " << temp->nextu->date_gain << endl;
cout << "Date Return: " << temp->nextu->date_return << endl;
temp->nextu = temp->nextu->next;
}
default:
cout << "Errorr" << endl;
}
}
else
cout << "No book to display" << endl;

}
void delete_book() {
book* temp = head_book;
int i;
cout << "ISBN of book you want to delete" << endl;
cin >> i;
if (head_book == nullptr) {
cout << "Nothing to delete" << endl;
}
else if (head_book != nullptr) {
if (check(i) == 1) {
book* temp = head_book;
while (temp->nextb->ISBN != i) {
temp = temp->nextb;
}
book* temp1 = temp;
temp1->nextb = temp->nextb;
delete temp;
cout << "Book deleted successfully" << endl;
}
else
cout << "Wrong entry" << endl;
}
else
cout << "^_^" << endl;
}
void display() {
// Display all the books available
book* temp = head_book;
while (temp != nullptr) {
cout << "Book Name: " << temp->name;
cout << "Book ISBN: " << temp->ISBN;
cout << "Book Availability: " << temp->status;
temp = temp->nextb;
}
cout << "Details of all Books completed" << endl;
}
void section_insert() {
cout << "Sections Available: A,B,C,D,E" << endl;
// Sections are already saved in the library
int n = 5;
head_section = new section;
head_section->sec = 'a';
section* temp = head_section;
}
};

int main() {
Library_System l1;
return 0;
}

Dijikstar

You might also like