Library Manegment System
Library Manegment System
[2012-13]
PROJECT ON
..
DEVELOPED BY Name Class Session ANNIE BESANT INTER COLLEGE AFFILIATED TO U.P. BOARD
SUBMITTED BY
(C.S. Department)
Deepak Yadav
Page 1
[2012-13]
CERTIFICATE
This is to certify that Mr./Miss.. student of ANNIE BESANT INTER COLLEGE has successfully completed his/her project report on .. during session 2011 2012 as requirement for class 12th Board Examination. We wish him/her all the best for the future.
Approved by
Date
Deepak Yadav
Page 2
[2012-13]
ACKNOWLEDEMENTS
No task is a single mans effort; co-operation and co-ordination of various people at various places go into the successful implementation. It is impossible to thank them individually but I hereby make a humble effort to thank some of them. First of all, I would like to thank.. for his continuing support and guidance throughout the progress of the project and finally the timely accomplishment of the same. I would also lime to mention the invaluable assistance by .. who provided most of the reference material for the project. Due to their efforts the project has been completed in due time with the least possible error. I wish to forward my sincere thanks to them and hope for the same kind of help in future. Last but not least, I wish to thank and deliver my heartfelt gratitude to everyone else who have encouraged and helped me for the preparation and completion of this project.
Name : Signature :
Deepak Yadav
Page 3
[2012-13]
SNO 1 2 3 4 5 6
TABLE OF CONTENTS TOPIC Cover page of the project Certificate Acknowledgements Table of contents INTRODUCTION SOFTWARE AND HARDWARE REQUIREMENTS Coding Screen shoots Bibliography Conclusion
7 8 9 10
Deepak Yadav
[2012-13]
INTRODUCTION
Mans quest for constant knowledge is what has resulted in todays sophisticated technological hi-tech lives of the 21st century man. As knowledge becomes the most critical resource and new, varied technologies evolve rapidly, IT plays a key role in fuelling the economic growth. The main objective of this project.. is to give us a feeling of application development in the real world. The twenty first century is slated to belong to the information technology. It is the new axis on which the world revolves and impels the global economy. Our development of this project on .. is our first step towards a dynamic multifaceted IT world.
Deepak Yadav
Page 5
[2012-13]
Software Requirements:
Operating System : Windows XP/ 2007 Programming Language : C++/C;
Deepak Yadav
Page 6
[2012-13]
Introduction of C++
C++ began as an expanded version of C. The C++ extensions were first invented by Bjarne Stroustrup in 1979 at Bell Laboratories in Murray Hill, New Jersey. He initially called the new language "C with Classes." However, in 1983 the name was changed to C++.
Object-based programming languages, Object-based programming is the style of programming that primarily supports encapsulation and object identity. Major features that are required for object-based programming are: Data encapsulation Data hiding and access mechanism Automatic initialization and clear-up of objects Operator overloading
Languages that support programming with objects are said to be object-based programming languages. They do not support inheritance and dynamic binding. Ad is a typical object-based programming language. . Classes: We just mentioned that objects contained that objects contain data, and code to manipulate that data. The entire set of data and code of an object can be made a user-defined data type with the help of a class. In fact, objects are variables of that class type. Once a class has been defined , we can create any number of objects belonging to that class. Each object is associated with the data of type class with which they are created. A class is thus a collection of objects of similar type. Foe example, mango, apple and orange are member of the class fruit. Classes are user-defined data types and behave like the built-in types of a programming language. The syntax is used to create an object is no different than the syntax used to create an integer object in C. If fruit has been defined as a class, then the statement: Fruit mango; Will create an object mango belonging to the class fruit.
1.3.3 Encapsulation:
Deepak Yadav
Page 7
LIBRARY [2012-13] The MANAGEMENT wrapping of data SYSTEM and functions into a single unit (called class) is known as encapsulation. Data
encapsulation is the most striking feature of a class. The data is not accessible to the outside world, and those functions, which are wrapped in the class, can access it. These function provide the
interface between the objects data and the program. This insulation of the data from direct access by the program is called data hiding .
1.3.4 Data Abstraction: Abstraction refers to the act of representing essential features with out including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost and functions to operate on these attributes. Sometimes, these are called data members because they hold information. The functions that operate on these data are called methods or member functions.
1.3.5 Inheritance Inheritance is the process by which objects of one class acquire the properties of objects of another class. It supports the concept of hierarchical classification. For example, the bird robin is a part of the class flying bird which is again a part of the class bird. The principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived
Deepak Yadav
Page 8
[2012-13]
CODING
Deepak Yadav
Page 9
[2012-13]
//*************************************************************** // HEADER FILE USED IN PROJECT //**************************************************************** #include<fstream.h> #include<conio.h> #include<stdio.h> #include<process.h> #include<string.h> #include<iomanip.h> //*************************************************************** // CLASS USED IN PROJECT //****************************************************************
class book { char bno[6]; char bname[50]; char aname[20]; public: void create_book() { cout<<"\nNEW BOOK ENTRY...\n"; cout<<"\nEnter The book no.";
cin>>bno; cout<<"\n\nEnter The Name of The Book "; Deepak Yadav Page 10
[2012-13]
cout<<"\n\n\nBook Created.."; }
void show_book() { cout<<"\nBook no. : "<<bno; cout<<"\nBook Name : "; puts(bname); cout<<"Author Name : "; puts(aname); } void modify_book() { cout<<"\nBook no. : "<<bno; cout<<"\nModify Book Name : "; gets(bname); cout<<"\nModify Author's Name of Book : "; gets(aname); } char* retbno() { return bno; } void report() {cout<<bno<<setw(30)<<bname<<setw(30)<<aname<<endl;} }; //class ends here
Deepak Yadav
Page 11
[2012-13]
char admno[6]; char name[20]; char stbno[6]; int token; public: void create_student() { clrscr(); cout<<"\nNEW STUDENT ENTRY...\n"; cout<<"\nEnter The admission no. "; cin>>admno; cout<<"\n\nEnter The Name of The Student "; gets(name); token=0; stbno[0]='/0'; cout<<"\n\nStudent Record Created.."; } void show_student() { cout<<"\nAdmission no. : "<<admno; cout<<"\nStudent Name : "; puts(name); cout<<"\nNo of Book issued : "<<token; if(token==1) cout<<"\nBook No "<<stbno; } void modify_student() { cout<<"\nAdmission no. : "<<admno; cout<<"\nModify Student Name : "; gets(name); } char* retadmno() { return admno; }
Deepak Yadav
Page 12
[2012-13]
//*************************************************************** // global declaration for stream object, object //**************************************************************** fstream fp,fp1; book bk; student st; //*************************************************************** // function to write in file //**************************************************************** void write_book() { char ch; Deepak Yadav Page 13
[2012-13]
clrscr(); bk.create_book(); fp.write((char*)&bk,sizeof(book)); cout<<"\n\nDo you want to add more record..(y/n?)"; cin>>ch; }while(ch=='y'||ch=='Y'); fp.close(); } void write_student() { char ch; fp.open("student.dat",ios::out|ios::app); do { st.create_student(); fp.write((char*)&st,sizeof(student)); cout<<"\n\ndo you want to add more record..(y/n?)"; cin>>ch; }while(ch=='y'||ch=='Y'); fp.close(); } //*************************************************************** // function to read specific record from file //**************************************************************** void display_spb(char n[]) { cout<<"\nBOOK DETAILS\n"; int flag=0; fp.open("book.dat",ios::in); while(fp.read((char*)&bk,sizeof(book))) { if(strcmpi(bk.retbno(),n)==0) { bk.show_book(); flag=1; } Deepak Yadav Page 14
[2012-13]
Page 15
[2012-13]
Page 16
[2012-13]
//*************************************************************** // function to delete record of file //**************************************************************** void delete_student() { char n[6]; int flag=0; clrscr(); cout<<"\n\n\n\tDELETE STUDENT..."; cout<<"\n\nEnter The admission no. of the Student You Want To Delete : "; cin>>n; fp.open("student.dat",ios::in|ios::out); fstream fp2; fp2.open("Temp.dat",ios::out); fp.seekg(0,ios::beg); while(fp.read((char*)&st,sizeof(student))) { if(strcmpi(st.retadmno(),n)!=0) fp2.write((char*)&st,sizeof(student)); else flag=1; } fp2.close(); fp.close(); remove("student.dat"); rename("Temp.dat","student.dat"); if(flag==1) cout<<"\n\n\tRecord Deleted .."; else cout<<"\n\nRecord not found"; getch(); } void delete_book() { char n[6]; clrscr(); Deepak Yadav Page 17
[2012-13]
fp.open("book.dat",ios::in|ios::out); fstream fp2; fp2.open("Temp.dat",ios::out); fp.seekg(0,ios::beg); while(fp.read((char*)&bk,sizeof(book))) { if(strcmpi(bk.retbno(),n)!=0) { fp2.write((char*)&bk,sizeof(book)); } } fp2.close(); fp.close(); remove("book.dat"); rename("Temp.dat","book.dat"); cout<<"\n\n\tRecord Deleted .."; getch(); }
//*************************************************************** // function to display all students list //**************************************************************** void display_alls() { clrscr(); fp.open("student.dat",ios::in); if(!fp) { cout<<"ERROR!!! FILE COULD NOT BE OPEN "; getch(); return; } cout<<"\n\n\t\tSTUDENT LIST\n\n"; cout<<"==================================================================\n"; cout<<"\tAdmission No."<<setw(10)<<"Name"<<setw(20)<<"Book Issued\n";
Deepak Yadav
Page 18
[2012-13]
cout<<"==================================================================\n"; while(fp.read((char*)&st,sizeof(student)))
st.report(); } fp.close(); getch(); } //*************************************************************** // function to display Books list //**************************************************************** void display_allb() { clrscr(); fp.open("book.dat",ios::in); if(!fp) { cout<<"ERROR!!! FILE COULD NOT BE OPEN "; getch(); return; } cout<<"\n\n\t\tBook LIST\n\n"; cout<<"==================================================================== =====\n"; cout<<"Book Number"<<setw(20)<<"Book Name"<<setw(25)<<"Author\n"; cout<<"==================================================================== =====\n"; while(fp.read((char*)&bk,sizeof(book))) { bk.report(); } fp.close(); getch(); Deepak Yadav Page 19
[2012-13]
//**************************************************************** void book_issue() { char sn[6],bn[6]; int found=0,flag=0; clrscr(); cout<<"\n\nBOOK ISSUE ..."; cout<<"\n\n\tEnter The student's admission no."; cin>>sn; fp.open("student.dat",ios::in|ios::out); fp1.open("book.dat",ios::in|ios::out); while(fp.read((char*)&st,sizeof(student)) && found==0) { if(strcmpi(st.retadmno(),sn)==0) { found=1; if(st.rettoken()==0) { cout<<"\n\n\tEnter the book no. "; cin>>bn; while(fp1.read((char*)&bk,sizeof(book))&& flag==0) { if(strcmpi(bk.retbno(),bn)==0) { bk.show_book(); flag=1; st.addtoken(); st.getstbno(bk.retbno()); int pos=-1*sizeof(st); fp.seekp(pos,ios::cur); fp.write((char*)&st,sizeof(student)); cout<<"\n\n\t Book issued successfully"; cout<<"\n\n\tPlease Note: Write current date in backside of book and"; cout <<"\n\tsubmit within 15 days fine Rs. 1 for each day after 15 days period";
Deepak Yadav
Page 20
[2012-13]
cout<<"You have not returned the last book "; } } if(found==0) cout<<"Student record not exist..."; getch(); fp.close(); fp1.close(); } //*************************************************************** // function to deposit book //**************************************************************** void book_deposit() { char sn[6],bn[6]; int found=0,flag=0,day,fine; clrscr(); cout<<"\n\nBOOK DEPOSIT ..."; cout<<"\n\n\tEnter The students admission no."; cin>>sn; fp.open("student.dat",ios::in|ios::out); fp1.open("book.dat",ios::in|ios::out); while(fp.read((char*)&st,sizeof(student)) && found==0) { if(strcmpi(st.retadmno(),sn)==0) { found=1; if(st.rettoken()==1) { while(fp1.read((char*)&bk,sizeof(book))&& flag==0) { if(strcmpi(bk.retbno(),st.retstbno())==0) { bk.show_book(); flag=1; Deepak Yadav Page 21
[2012-13]
cout<<"\n\nFine has to deposited Rs. "<<fine; } st.resettoken(); int pos=-1*sizeof(st); fp.seekp(pos,ios::cur); fp.write((char*)&st,sizeof(student)); cout<<"\n\n\t Book deposited successfully"; } } if(flag==0) cout<<"Book no does not exist"; } else cout<<"No book is issued..please check!!"; } } if(found==0) cout<<"Student record not exist..."; getch(); fp.close(); fp1.close(); }
//*************************************************************** // INTRODUCTION FUNCTION //**************************************************************** void intro() { clrscr(); gotoxy(35,11); cout<<"------WEL COME ------\n"; cout<<"\n\n::::::::::::::::::::::::::::::::\n\n";
Deepak Yadav
Page 22
[2012-13]
cout<<"________________\n\n"; cout<<"\n\nMADE BY : Akash Kashyap"; cout<<"\n\nSCHOOL : ANNIE BESANT INTER COLLEGE"; cout<<"__________________________\n"; cout<<"---------------------------------------------\n"; getch(); }
//*************************************************************** // ADMINISTRATOR MENU FUNCTION //**************************************************************** void admin_menu() { clrscr(); int ch2; cout<<"----------------------------------------------------------------------------------------------------------------"; cout<<"----------------------------------------------------------------------------------------------------------------"; cout<<"\n\n\n\tMAIN MENU"; cout<<"\n\n\t1.CREATE STUDENT RECORD"; cout<<"\n\n\t2.DISPLAY ALL STUDENTS RECORD"; cout<<"\n\n\t3.DISPLAY SPECIFIC STUDENT RECORD "; cout<<"\n\n\t4.MODIFY STUDENT RECORD"; cout<<"\n\n\t5.DELETE STUDENT RECORD"; cout<<"\n\n\t6.CREATE BOOK "; cout<<"\n\n\t7.DISPLAY ALL BOOKS "; cout<<"\n\n\t8.DISPLAY SPECIFIC BOOK "; cout<<"\n\n\t9.MODIFY BOOK "; cout<<"\n\n\t10.DELETE BOOK "; cout<<"\n\n\t11.BACK TO MAIN MENU"; cout<<"----------------------------------------------------------------------------------------------------------------"; cout<<"\n\n\tPlease Enter Your Choice (1-11) "; cin>>ch2; Deepak Yadav Page 23
[2012-13]
char num[6]; clrscr(); cout<<"\n\n\tPlease Enter The Admission No. "; cin>>num; display_sps(num); break; case 4: modify_student();break; case 5: delete_student();break; case 6: clrscr(); write_book();break; case 7: display_allb();break; case 8: { char num[6]; clrscr(); cout<<"\n\n\tPlease Enter The book No. "; cin>>num; display_spb(num); break; } case 9: modify_book();break; case 10: delete_book();break; case 11: return; default:cout<<"\a"; } admin_menu(); } //*************************************************************** // THE MAIN FUNCTION OF PROGRAM //**************************************************************** void main() { char ch; intro(); do Deepak Yadav Page 24
[2012-13]
cout<<"\n\n\t04. EXIT"; cout<<"\n\n\tPlease Select Your Option (1-4) "; ch=getche(); switch(ch) { case '1':clrscr(); book_issue(); break; case '2':book_deposit(); break; case '3':admin_menu(); break; case '4':exit(0); default :cout<<"\a"; } }while(ch!='4'); } //*************************************************************** // //***************************************************************
Introduction of C++
C++ began as an expanded version of C. The C++ extensions were first invented by Bjarne Stroustrup in 1979 at Bell Laboratories in Murray Hill, New Jersey. He initially called the new language "C with Classes." However, in 1983 the name was changed to C++.
Object-based programming languages, Object-based programming is the style of programming that primarily supports encapsulation and object identity. Major features that are required for object-based programming are: Data encapsulation Data hiding and access mechanism
Deepak Yadav
Page 25
[2012-13]
Languages that support programming with objects are said to be object-based programming languages. They do not support inheritance and dynamic binding. Ad is a typical object-based programming language. . Classes: We just mentioned that objects contained that objects contain data, and code to manipulate that data. The entire set of data and code of an object can be made a user-defined data type with the help of a class. In fact, objects are variables of that class type. Once a class has been defined , we can create any number of objects belonging to that class. Each object is associated with the data of type class with which they are created. A class is thus a collection of objects of similar type. Foe example, mango, apple and orange are member of the class fruit. Classes are user-defined data types and behave like the built-in types of a programming language. The syntax is used to create an object is no different than the syntax used to create an integer object in C. If fruit has been defined as a class, then the statement: Fruit mango; Will create an object mango belonging to the class fruit.
1.3.3 Encapsulation: The wrapping of data and functions into a single unit (called class) is known as encapsulation. Data encapsulation is the most striking feature of a class. The data is not accessible to the outside world, and those functions, which are wrapped in the class, can access it. These function provide the
interface between the objects data and the program. This insulation of the data from direct access by the program is called data hiding .
1.3.6 Data Abstraction: Abstraction refers to the act of representing essential features with out including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost and functions to operate on these attributes. Sometimes, these are called data members because they hold information. The functions that operate on these data are called methods or member functions.
Deepak Yadav
Page 26
[2012-13]
Inheritance is the process by which objects of one class acquire the properties of objects of another class. It supports the concept of hierarchical classification. For example, the bird robin is a part of the
class flying bird which is again a part of the class bird. The principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived
Deepak Yadav
Page 27
[2012-13]
SCREEN
MAIN SCREEN
Deepak Yadav
Page 28
[2012-13]
ADMINISTRATOR MENU
Deepak Yadav
Page 29
[2012-13]
Deepak Yadav
Page 30
BIBLOGRAPHY
[2012-13]
Websites Referred : www.google.com www.sourcecode.com Book Referred: C++ in depth C++ class XIIth U.P Board Sumit Deepti Mittal
Deepak Yadav
Page 31
[2012-13]
CONCLUSION
The successful completion of the project gave us a sense of self- achievement. Project making involved immense hard work, solving practical problems and preparation of the final project report. Such practical approach leads to a better understanding of the lessons. We conclude with a firm belief that such practical experiences lead to constant learning and the same would not have been accomplished without the joint efforts of our teachers, friends and our family.
Deepak Yadav
Page 32