Library Management System

Library Management System 


#include<iostream>

#include<string>

using namespace std;

class Library{

	int books;

	string name, author, publisher, issueDate, returnDate; int isbnNo;

public:

	void create()

	{



		cout << "Enter the name of the book:"; getline(cin, name);

		cout << "Enter the author name:"; getline(cin, author);

		cout << "Enter the ISBN number(in integer):"; cin >> isbnNo; cin.ignore();

		cout << "Enter the publisher name:"; getline(cin, publisher);

		cout << "Enter the issue date:"; getline(cin, issueDate);

		cout << "Enter the return date:"; getline(cin, returnDate);



	}

	void retrieve(Library *l, int size, int a)

	{

		int count = 0;

		for (int i = 0; i < size; i++)

		{

			if (l[i].isbnNo == a)

			{

				l[i].author = " ";

				l[i].books = l[i].books - 1;

				l[i].isbnNo = 0;

				l[i].issueDate = " ";

				l[i].name = " ";

				l[i].publisher = " ";

				l[i].returnDate = " ";

				count = 1;

			}

		}

		if (count = 0)

		{

			cout << "Your isbn number is not found" << endl;

		}

		else

			cout << "Book cancell successfully" << endl;



	}

	void update(Library *l, int size)

	{

		int a, count = 0;

		cout << "Enter the isbn number to update information:";

		cin >> a; cin.ignore();

		for (int i = 0; i < size; i++)

		{

			if (a == l[i].isbnNo)

			{

				cout << "Enter the name of the book:"; getline(cin, l[i].name);

				cout << "Enter the author name:"; getline(cin, l[i].author);

				cout << "Enter the ISBN number:"; cin >> l[i].isbnNo; cin.ignore();

				cout << "Enter the publisher name:"; getline(cin, l[i].publisher);

				cout << "Enter the issue date:"; getline(cin, l[i].issueDate);

				cout << "Enter the return date:"; getline(cin, l[i].returnDate);

				count = 1;

			}

		}

		if (count = 0)

		{

			cout << "Your isbn number is not found" << endl;

		}

		else

			cout << "Information is update" << endl;

	}

	void Delete(Library *l, int size)

	{

		int a, count = 0;

		cout << "Enter the isbn number to delete book:"; cin >> a; cin.ignore();

		for (int i = 0; i < size; i++)

		{

			if (a == l[i].isbnNo)

			{

				delete[i]l;

				count = 1;

			}

		}

		if (count = 0)

		{

			cout << "Your isbn number is not found" << endl;

		}

		else

			cout << "Book deleted successfully" << endl;

	}

	void search(Library *l, int size)

	{

		int a, count = 0;

		cout << "Enter the isbn number to search book:";

		cin >> a;

		for (int i = 0; i < size; i++)

		{

			if (a == l[i].isbnNo)

			{

				cout << "Your isbn number is:" << l[i].isbnNo << endl;

				cout << "Your name is:" << l[i].name << endl;

				cout << "Your author name is:" << l[i].author << endl;

				cout << "Your publisher is:" << l[i].publisher << endl;

				cout << "Your issue date is:" << l[i].issueDate << endl;

				cout << "Your return date is:" << l[i].returnDate << endl;

				count = 1;

				system("pause");

			}

		}

		if (count = 0)

		{

			cout << "Your isbn number is not found" << endl;

		}

		else

			cout << "Search successful" << endl;

	}

	void issue(Library *l, int size)

	{

		int a, count = 0;

		cout << "Enter the isbn number to check issue date:"; cin >> a; cin.ignore();

		for (int i = 0; i < size; i++)

		{

			if (a == l[i].isbnNo)

			{

				cout << "Your issue date is:" << l[i].issueDate << endl;

				count = 1;

			}

		}

		if (count = 0)

		{

			cout << "Your isbn number is not found" << endl;

		}

		else

			cout << "issue date checking successful" << endl;

	}

	void Return(Library *l, int size)

	{

		int a, count = 0;

		cout << "Enter the isbn number to check return date:"; cin >> a; cin.ignore();

		for (int i = 0; i < size; i++)

		{

			if (a == l[i].isbnNo)

			{

				cout << "Your return date is:" << l[i].returnDate << endl;

				count = 1;

			}

		}

		if (count = 0)

		{

			cout << "Your isbn number is not found" << endl;

		}

		else

			cout << "issue date checking successful" << endl;

	}





};



int main()

{

	Library *lib = new Library[50];

	int no;

	cout << "How many books do you want to enter:";

	cin >> no;

	cin.ignore();

	for (int i = 0; i < no; i++)

	{

		(lib + i)->create();

		cout << endl;

	}

	int n = 0;

	while (n != 7)

	{

		system("cls");

		cout << "*******************Enter the choice*******************" << endl;

		cout << "Enter 1 to cancel book" << endl;

		cout << "Enter 2 to update book" << endl;

		cout << "Enter 3 to search the book" << endl;

		cout << "Enter 4 to check issue date" << endl;

		cout << "Enter 5 to check return date of book" << endl;

		cout << "Enter 6 to delete the book" << endl;

		cout << "Enter 7 to cancel" << endl;

		cout << "*******************************************************" << endl;

		cin >> n;

		cin.ignore();

		switch (n)

		{

		case 1:

		{

				  int a;

				  cout << "Enter the isbn number to cancel book:"; cin >> a; cin.ignore();

				  lib->retrieve(lib, no, a);

				  break;

		}

		case 2:

		{

				  lib->update(lib, no);

				  break;

		}

		case 3:

		{

				  lib->search(lib, no);

				  break;

		}

		case 4:

		{

				  lib->issue(lib, no);

				  break;

		}

		case 5:

		{

				  lib->Return(lib, no);

				  break;

		}

		case 6:

		{

				  lib->Delete(lib, no);

				  break;

		}

		case 7:

		{

				  cout << "Thank You So Much to use our sevices" << endl;

				  delete[]lib;

				  break;

		}

		default:

		{

				   cout << "This option is not available" << endl;

				   cout << "Thank U So Much to use Our Services" << endl;

		}

		}

	}

	getchar();

	getchar();

	return 0;

}       

          

       
 

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........