18
C++ Language: The Project I have undertaken is written in C++ Programming language and it supports Object Oriented Programming (OOP). C++ is an extension C programming language. Bjarne Stoutstrup created it in 1980. It is a deviation form the traditional procedural languages in the sense that it follows OOP. The fundamental idea behind OOP language is to combine both data and its functions into a single unit called object. 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. Objects provide an approach to program organization, while helping to maintain the integrity of the program data.

Library Management Project - C++

Embed Size (px)

DESCRIPTION

Library Management project created in 12th standard in C++.

Citation preview

Page 1: Library Management Project - C++

C++ Language:The Project I have undertaken is written in C++ Programming language and it supports Object Oriented Programming (OOP).

C++ is an extension C programming language. Bjarne Stoutstrup created it in 1980. It is a deviation form the traditional procedural languages in the sense that it follows OOP.The fundamental idea behind OOP language is to combine both data and its functions into a single unit called object.

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.

Objects provide an approach to program organization, while helping to maintain the integrity of the program data.

Page 2: Library Management Project - C++

User manual

“THE FIRST MENU THAT APPERARS ON THE SCREEN IN AS FOLLOWS. THE USER IS THEN ASKED TO ENTER HIS CHOICE.”

OPTION 1-BOOK LIBRARY

“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.”

OPTION 1 IN THE BOOK MENU

“IF THE USER CHOOSES OPTION 1 THEN THE USER IS ASKED TO ENTER THE FOLLOWING DETAILS”

“IF THE USER WANTS TO ENTER MORE RECORDS HE HAS TO ENTER Y OR OTHERWISE N AND IT WILL RETURN TO THE BOOKS MENU”

OPTION 2 IN THE BOOK MENU

“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”

OPTION 3 IN THE BOOK MENU“IF THE USER CHOOSES OPTION 3, THEN ALL THE BOOK RECORDS THAT THE USER HAS ENTERED WILL BE DISPLAYED ON THE SCREEN”

OPTION 4 IN THE BOOK MENU“IF THE USER CHOOSES OPTION 4, THEN USER IS ASKED TO ENTER THE BOOK CODE OF THE BOOK HE WANTS TO VIEW AND ONLY THAT BOOK WILL BE DISPLAYED”

Page 3: Library Management Project - C++

OPTION 5IN THE BOOK MENU

“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”

OPTION 6 IN THE BOOK MENU“IF THE USER CHOOSES OPTION 6, THEN THE FOLLOWING MENU APPERAS ON THE SCREEN AND HE GOES TO THE MAIN MENU”

OPTION 2: MEMBERS DIRECTORY“IF THE USER CHOOSES OPTION 2, THEN THE FOLLOWING MENU APPERAS ON THER SCREEN. THEN THE USER IS ASKED TO ENTER HIS CHOICE OF OPERATION TO BE PERFORMED IN THE MEMBERS LIBRABY”

OPTION 1 IN THE MEMBER MENU“IF THE USER CHOOSES OPTION 1, THEN THE FOLLOWING MENU APPEARS ON SCREEN THEN THE USER IS ASKED TO ENTER HIS DETAILS”

“IF THE USER WANTS TO ENTER MORE RECORDS HE HAS TO ENTER Y OR OTHERWISE N AND IT WILL RETURN TO THE BOOKS MENU”

Page 4: Library Management Project - C++

OPTION 2 IN THE MEMBERS MENU“IF THE USER CHOOSES OPTION 2 THEN THE USER IS ASKED TO ENTER THE MEMBER CODE HE WANTS TO DELETE AFTER THAT THE MEMBER WILL BE DELETED”

OPIOTION 3 IN THE MEMBERS MENU

“IF THE USER CHOOSES OPTION 3 THEN ALL THE MEMBER RECORDS THAT THE USER HAS ENTERED WILL BE DISPLAYED

OPTION 4 IN THE MEMBERS M,ENU“IF THE USER CHOOSES OPTION 4 THEN THE USER IS ASKED TO ENTER THE MEMBER CODE OF THE BOOK HE WANTS TO VIEW AND ONLY THAT BOOK WILL BE DISPLAYED

OPTION 5 IN THE MEMBERS MENU“IF THE USER CHOOSES OPTION 5. HE IS THEN ASKED TO ENTER THE MEMBER CODE HE WANTS TO MODIFY IF THE CODE IS VALID HE IS ASKED TO ENTER THE NEW DETAILS FOR THAT BOOK. OTHERWISE IT RETURNS TO THE MEMBERS MENU:

OPTION 6 IN THE MEMBERS MENU

Page 5: Library Management Project - C++

//This function displays members menuVoid mem_menu(){ Int choice,ex=0;

do { Clrscr(); Gotoxy(20,3); Cout<<”************************************”; Gotoxy(20,4); Cout<<”***WELCOME TO MEMBER DIRECTORY”***; Gotoxy(20,5); Cout<<”************************************”; Gotoxy(32,6); Cout<<”1.Addition”;

Page 6: Library Management Project - C++

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 menuVoid 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);

Page 7: Library Management Project - C++

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); }

Page 8: Library Management Project - C++

//BOOK CLASS FNS.

//This program adds a book to database

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”);

}

//This program deletes book information by code

Void del_book(){ ofstream ofile(“nfirst.dat”,ios::binary|ios::out); ifstream ifile(“first.dat”,ios::binary|ios::in); book p; int resno;

Page 9: Library Management Project - C++

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();

Page 10: Library Management Project - C++

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();

Cout<<”\n Press any key to return to the menu”; Getch(); Ofile.close(); Remove(“first.dat”); Rename(“nfirst.dat”,”first.dat”); Remove(“nfirst.dat”); }

//This program displays book information by codeVoid disp_book() { 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();

Page 11: Library Management Project - C++

} 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(); }

//This program displays all booksVoid book::all_books() { Ifstream ifile; Ifile.open(“first.dat”,ios::binary|ios::in); Clrscr(); Ifile.read((char*)&c,sizeof(book));Cout<<endl;Cout<<”\n_____________________________________________”;Cout<<”\n ** BOOKS INFORMATION TABLE ** “;Cout<<”\n_____________________________________________”;Cout<<setw(10)<<”Code”<<setw(15)<<”Name”<<setw(15)<<”Author”<<setw(20)<<”Book Price”;Cout<<endl;Cout<<”\n_____________________________________________”;Cout<<endl;If(!ifile){cout<<endl<<endl;Cout<<”~~~~~~~* NO INPUT!!! *~~~~~~~~~~~\n”;Getch();}Else{ While(ifile){Cout<<setw(9)<<c.code<<setw(14)<<c.name<<setw(14)<<c.author;Cout<<setw(19)<<c.price;Cout<<endl;Ifile.read((char*)&c,sizeof(c)); }}Cout<<endl<<endl<<endl;

Cout<<”~~~~~~~~~~~~~~~~~~~~**~~~~~~~~~~~~~~~~~~~~~~~\n”; Cout<<”\n Press any key to continue…”;

Page 12: Library Management Project - C++

Getch();Ifile.close();}

ANAND PROGRAM….START…

//Transaction Fns.

//This fuction issues a book for the memberVoid issue_book() { Ofstream ofile(“nissue.dat”,ios::binary|ios::app); Ifstream ifile(“issue.dat”,ios::binary|ios::in); Transaction m; Book p; Ifile.read((char*)&m, sizeof(m)); If(!ifile) {cout<<” “;} Else {do { Ofile.write((char*)&m, sizeof(m)); Ifile.read((car*)&m, sizeof(m));

Page 13: Library Management Project - C++

}while(ifile);} Ifile.close(); Char choice = ‘n’; Do { p.all_books(); m.tread_data(); ofile.write((char*)&m, sizeof(transaction)); m.tshow_data(); cout<<”\n The book has been issued”; cout<<”\n Do you want to issue more records \t”; cin>>choice; }while(choice==’y’||choice==’Y’); Ofile.close(); Remove(“issue.dat”); Rename(“nissue.dat”,”issue.dat”);

}

//This function displays all issued booksVoid transaction::disp_issue() { Ifstream ifile; Ifile.open(“issue.dat”,ios::binary|ios::in); Clrscr(); Ifile.read((char*)&s, sizeof(transaction)); Cout<<endl;

Cout<<”\n_____________________________________________”; Cout<<”\n ** ISSUED BOOKS INFORMATION TABLE ** “; Cout<<”\n____________________________________________\n”; Cout<<” “<<”Member”<<” Book Code”<<” Book Name”<<” Price “; Cout<<endl;

Page 14: Library Management Project - C++