OOP Mini Project (Library Management)
OOP Mini Project (Library Management)
Objective: The objective behind developing this project is to create a library management
system that can be used to manage the book details using a simple and easy-to-use
user interface.
2.Encapsulation:
Data Protection:
Encapsulation is nothing but the data hiding. The act of
combining data and functions into a single unit (called class)
(Encapsulation). Encapsulation can be used to hide sensitive
data from the user. In our program we used private
attributes (i.e. price, stock) so that they can’t be accessed
directly from outside the class and public methods were
used to access private attribute like insertData, display,
search , check availability.
Interface Control:
By providing only the essential details to the user( i.e.
insertData, display, search , checkavailability), interface
control is used to provide data abstraction meaning user
doesn’t know what happens in background.
3.Inheritance:
Reuasability:
Inheritance supports the concept of “reusability” i.e.
when we want to create a new class and there is already a
class that includes some of the code that we want, we can
derive our new class from the existing class. This helps in
reducing duplication of code. For example if there exists a
member function in a class and you want to create another
class which is slightly modifies the already existing member
function. In this case you can define that member function
as a derived class member.
Hierarchical Structure:
This structure helps to manage relationships and similarities
between different entities in the library by the mean of their
arrangement in a hierarchy. For example, there can be an
elementary observation that all types of members share
common details and hence they should be incorporated in
the base Member class. However, this method might need
some customization for certain classes so it can be redefined
there.
4.Polymorphism:
Method Overloading and Overriding:
Polymorphism allows method to perform different things
based on the object that is calling it. Like in both
StudentMember and FacultyMember class have a method
search(), each can provides its own implementation of
method search() but share the same method name. So same
function performs different types of processing based on the
number and type of classes a objects belongs to and
flexibility is provided by implementing objects.
Dynamic Binding:
Polymorphism enables dynamic binding (or run time
binding) – the object’s method which is to be invoked on is
decided during run time. This can boost the system
performance and improve code understandability.
5.Abstraction:
Simplifying Complexity:
Abstraction means hiding the real complexity behind a series
of simpler interfaces, or beneath a higher-level programming
model. For example, customers of the Book class don’t need
to know how the search algorithm is implemented; they
only have to provide a value and call the search() method.
Interface Design:
The system provides an interface to work with books where
a user can use the functionality of the sytem without
knowledge of the details of implementation.
6.Composition:
Combining Objects:
A Library class can contain collections of objects of
another class. We can have an array or linked list of
books in the class Library, but actually Book class
and Member class are separate classes which we
have to define separately. This composition will help
us to model more complex real world objects.
#include<iostream>
#include<string.h>
#include<stdlib.h>
}
int main()
{
int ch,n,i,flag=0,copies,key=0;
book b[100];
char bname[50];
char key_title[50],key_author[50];
do
{
cout<<"\n************Book Store*******************";
cout<<"\n 1.Insert Details of book \n 2.Display \n 3.search \n 4.exit";
cout<<"\n Enter Your Choice:";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n How many books data u want to enter";
cin>>n;
for(i=0;i<n;i++)
{
b[i].insertdata();
}
break;
case 2:
cout<<"\n"<<"TITLE"<<"\t \t
"<<"AUTHOR"<<"\t\t"<<"PUBLISHER"<<"\t\t"<<"PRICE"<<"\t
"<<"STOCK";
for(i=0;i<n;i++)
{
cout<<"\n";
b[i].display();
}
break;
case 3:
cout<<"\n Enter title of required book";
cin>>key_title;
cout<<"\n Enter author of required book";
cin>>key_author;
for(i=0;i<n;i++)
{
if(b[i].search(key_title,key_author))
{
flag=1;
cout<<"\n"<<"TITLE"<<"\t \t
"<<"AUTHOR"<<"\t\t"<<"PUBLISHER"<<"\t\t"<<"PRICE"<<"\t
"<<"STOCK";
b[i].display();
//break;
key=i;
}
}
if(flag==1)
cout<<"\n Book is available";
else
{
cout<<"\n book is Not available";
break;
}
if(flag==1)
{
cout<<"\n Please enter the required number of copies of the
book";
cin>>copies;
b[key].nocopies(copies);
}
break;
case 4: exit(EXIT_SUCCESS);
break;
default :
cout<<"\n Wrong Choice";
break;
}
}
while(ch!=5);
return 0;
}
Output:
Conclusion:
These are the OOP principles that help to develop a Library Management
System more manageable, scalable and maintainable. With the use of the
concepts such as encapsulation, inheritance, polymorphism and abstraction
we can easily build and manage libraries. We can also extend their
functionalities in future using this built library system. This is not only easy
to implement and reuse but it also makes sense in real world making our user
interface more friendlier.