Library Management Project - C++
Library Management Project - C++
Library Management Project - C++
The Project I have undertaken is written in C++ Programming language and it supports
Object Oriented Programming (OOP).
An object’s functions,called member functions in C++, typically provide the only way to
access its data. If you want to read a data item on an object, you call a member function
in an object. It will read the item and return the value to you. You cant access the data
directly. The data is hidden, so its safe form the acceidental alteration. Data and its
functions are to be encapsulated into a single entity.
“IF THE USER CHOOSES OPTION 1, THEN THE FOLLOWING MENU APPERAS
ON THE SCREEN. THEN THE USER IS ASKED TO ENTER HIS CHOICE OF
OPERATION TO BE PERFORMED IN THE BOOK LIBRARY.”
“IF THE USER CHOOSES OPTION 1 THEN THE USER IS ASKED TO ENTER THE
FOLLOWING DETAILS”
“IF THE USER CHOOSES OPTION 2, THEN HE ASKED TO ENTER THE BOOK
CODE HE WANTES TO DELETE AFTER WHICH THE SPECIFIED BOOK WILL
BE DELETED”
“IF THE USER CHOOSES OPTION 5 THEN THE USER IS ASKED TO ENTER THE
BOOK CODE HE WANTS TO MODIFY, IF THE CODE IF INVALIED HE IS
ASKED TO ENTER THE NEW DETAILS FOR THAT BOOK. OTHERWISE IT
RETURNS TO THE BOOK’S MENU”
“IF THE USER CHOOSES OPTION 3 THEN ALL THE MEMBER RECORDS THAT
THE USER HAS ENTERED WILL BE DISPLAYED
do
{
Clrscr();
Gotoxy(20,3);
Cout<<”************************************”;
Gotoxy(20,4);
Cout<<”***WELCOME TO MEMBER DIRECTORY”***;
Gotoxy(20,5);
Cout<<”************************************”;
Gotoxy(32,6);
Cout<<”1.Addition”;
Gotoxy(32,7);
Cout<<”2.Deletion”;
Gotoxy(32,8);
Cout<<”3.Display list”;
Gotoxy(32,9);
Cout<<”4.Display by code”;
Gotoxy(32,10);
Cout<<”5.Modification”;
Gotoxy(32,11);
Cout<<”6.Exit”;
Gotoxy(20,12);
Cout<<”************************************”;
Gotoxy(20,14);
Cout<<”PLEASE ENTER YOUR CHOICE----> “;
Cin>>choice;
Switch(choice)
{
Case 1: add_mem();
break;
Case 2: del_mem();
break;
Case 3: n.all_mems();
break;
Case 4: disp_mem();
break;
Case 5: mod_mem();
break;
}
}while(!ex);
}
//This function displays transaction menu
Void trans_menu()
{
Int choice,ex=0;
Do
{
Clrscr();
Gotoxy(20,3);
Cout<<”*********************************************”;
Gotoxy(20,4);
Cout<<”* THE TRANSACTION MENU *”;
Gotoxy(20,5);
Cout<<”*********************************************”;
Gotoxy(28,6);
Cout<<”1.ISSUE A BOOK”;
Gotoxy(28,6);
Cout<<”2.DISPLAY AN ISSUED BOOK”;
Gotoxy(28,8);
Cout<<”3.RECEIVE A BOOK”;
Gotoxy(28,9);
Cout<<”4.E***X***I***T”;
Gotoxy(20,10);
Cout<<”PLEASE ENTER YOUR CHOICE---> “;
Cin>>choice;
Switch(choice)
{
Case 1: issue_book();
Break;
Case 2: s.disp_issue():
Break;
Case 3: receive_book();
Break;
Case 4: ex=1;
Mainmenu():
Break;
}
}while(!ex);
}
Void exit()
{
Clrscr();
Gotoxy(10,5);
Cout<<”~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n’;
Gotoxy(10,6):
Cout<<” THANK YOU FOR YOUR COOPERATION \n”;
Gotoxy(10,7);
Cout<<” PROGRAM IS CREATED BY ANAND & HUZEIFA \n”;
Gotoxy(10,8);
Cout<<” IT HAS REALLY BEEN A VERY GOOD EXPERIENCE. \n”;
Gotoxy(10,9);
Cout<<” THIS IS AN INTERESTING TOPIC TO WORK ON.\n”;
Gotoxy(10,10);
Cout<<” WE WOULD LIKE TO THANK MRS.SMITHA RAJIV \n”;
Gotoxy(10,11);
Cout<<” FOR HER TIME,EFFORT AND MORE OVER PATIENCE \n”;
Cout<<” ***************************** \n”;
Cout<<”~~~~~~~~~*HOPE YOU HAVE A GOOD DAY*~~~~~~~~~”;
Cout<<” *****************************”;
Exit(0);
}
//BOOK CLASS FNS.
Void add_book()
{
Ofstream ofile(“nfirst.dat”,ios::binary|ios::app);
Ifstream ifile(“first.dat”,ios::binary|ios::in);
Book p:
Ifile.read((char*)&p, sizeof(p));
If(!ifile)
{cout<<” “;}
Else
{do
{
Ofile.write((char*)&p, sizeof(p));
Ifile.read((char*)&p, sizeof(p));
}while(ifile);}
Ifile.close();
Char choice = ‘n’;
Do
{
Clrscr();
p.read_data();
ofile.write((char*)&p, sizeof(book));
cout<<”\n The book has been added to the database’;
cout<<”\n Do you want to add more records \t”;
cin>>choice;
}while(choice==’y’||choice==’Y’);
Ofile.close();
Remove(“first.dat”);
Rename(“nfirst.dat”,”first.dat”);
Void del_book()
{
ofstream ofile(“nfirst.dat”,ios::binary|ios::out);
ifstream ifile(“first.dat”,ios::binary|ios::in);
book p;
int resno;
cout<<”\n Enter the Book Code \t”;
cin>>resno;
ifile.read((char*)&p, sizeof(p));
do
{
Int infono;
Infono=p.res_no();
If(infono==resno)
{
Ifile.read((char*)&p, sizeof(p));
Cout<<”\n The File Has Been Deleted”;
}
Else
{
Ofile.write((char*)&p, sizeof(p));
Ifile.read((char*)&p, sizeof(p));
Cout<<” “;
}
}while(ifile);
Ifile.close();
Ofile.close();
Remove(“first.dat”);
Rename(“nfirst.dat”,”first.dat”);
Cout<<”\n Press any key to continue…\n”;
Getch();
}
//This program is used to modify book information by code
Void mod_book()
{
Ifstream ifile(“first.dat”,ios::binary|ios::in);
Ofstream ofile(“nfirst.dat”,ios::binary|ios::out);
Book p;
Int resno;
Cout<<”\ Enter the code of the book \n”;
Cin>>resno;
Ifile.read((char*)&p, sizeof(p));
While(ifile)
{
Int infono;
Infono=p.res_no();
If(!file)
{cout<<”\n WRONG CODE”;
}
Else if(infono==resno)
{
Cout<<”\n Enter the new details\n”;
p.read_data();
cout<<”\n The file has been modified”;
}
Ofile.write((char*)&p, sizeof(p));
Ifile.read((char*)&p, sizeof(p));
Ifile.close();
{
Ifstream ifile(“first.dat”,ios::binary|binary|ios::in);
Book p;
Int resno;
Int infono;
Clrscr();
Cout<<”\n Enter the code number \t”;
Cin>>resno;
Ifile.read((char*)&p, sizeof(p));
Do
{
Infono=p.res_no();
If(infono==resno)
{
p.display_data();
cout<<”\n Press any key to continue…”;
getch();
}
Ifile.read((char*)&p, sizeof(p));
}while(ifile);
{
If(infono!=resno)
Cout<<”\n File does not exist “<<endl;
Cout<<” Press any key to continue…”;
}
Ifile.close();
}
Cout<<”~~~~~~~~~~~~~~~~~~~~**~~~~~~~~~~~~~~~~~~~~~~~\n”;
Cout<<”\n Press any key to continue…”;
Getch();
Ifile.close();
}
ANAND PROGRAM….START…
//Transaction Fns.
Cout<<”\n_____________________________________________”;
Cout<<”\n ** ISSUED BOOKS INFORMATION TABLE ** “;
Cout<<”\n____________________________________________\n”;
Cout<<” “<<”Member”<<” Book Code”<<” Book Name”<<” Price “;
Cout<<endl;