0% found this document useful (0 votes)
35 views

OOP Mini Project (Library Management)

Uploaded by

kehava4732
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

OOP Mini Project (Library Management)

Uploaded by

kehava4732
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

 AIM: Library Mnagement.

 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.

 Theory: Library Management System is based on Object Oriented Programming which is a


structured way of dealing with real-world objects or concepts.

1.Classes and Objects:


Classes:
In OOP, a class is an implementation of the type
abstraction. All classes group data members (attributes)
with members functions that work on them. In our system,
we have so far introduced classes like Book (which
represents a book entity with attributes such as title, author,
publisher, price and stock).
Object:
An object is something that manifests a class. A class is
created when a specific set of parameters is passed to it.
(e.g. The book thus put into the system is a specific object of
the Bookclass, which allows us to manage as many books as
we want to, regardless of their individual characteristics.)

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.

 Program(For Library Management):

#include<iostream>
#include<string.h>
#include<stdlib.h>

using namespace std;


class book
{
char author[20];
char title[20];
char publisher[20];
double price;
int stock;
public:
book();
void insertdata();
void display();
int search(char[],char[]);
void nocopies(int);
};
book::book()
{
char *author=new char[50];
char * title=new char[50];
char *publisher=new char[50];
price=0;
stock=0;
}
void book::insertdata()
{
cout<<"\n Enter the name of Book:";
cin>>title;
cout<<"\n Enter The Name Of Author:";
cin>>author;
cout<<"\n Enter The name of Publisher:";
cin>>publisher;
cout<<"\n Enter the Price of book:";
cin>>price;
cout<<"\n Enter Stock of book:";
cin>>stock;
}
void book::display()
{
cout<<"\n "<<title<<"\t\t "<<author<<"\t\t "<<publisher<<" \t\t\t
"<<price<<"\t "<<stock;
}
int book::search(char t[],char a[])
{
if(strcmp(title,t)&&(strcmp(author,a)))
{
return 0;
}
else
{
return 1;
}
}
void book::nocopies(int num)
{
if(stock>=num)
{
cout<<"\n Title is avilable";
cout<<"\n Cost of"<<num<<"Books is Rs."<<(price*num);
}
else
{
cout<<"\n Required copies not in stock";
}

}
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.

You might also like