March 2, 2012

Digital Library Management System

Explanation of OOP basics with the help of Digital Library Management System

Problem: The purpose of the Library Management system is to allow for storing details of a large number of books, magazines, Journals, thesis and allow for add, search, borrow, return facilities separately to administrator/Librarian, staff and students. Different privileges are given to different types of users.

Lets break this system in OOP partitions:

1. You will have to identify the main entities (objects) for this system.

Library
Administrator/Librarian
Staff
Students

2. You will have to find out the relationships between these objects.

One way association
Two way association
Binary association
Composition
Aggregation

3. You will have to find the necessary attributes and functions that need to be associated with each object to implement the functionality mentioned above.

Library:
Attributes:
i) Name
ii) Interface
iii) Space

Function:
i) Store detail of data
ii) Add
iii) Search
iv) Return
v) Borrow

Administrator:
Attributes:
i) Name
ii) Gender
iii) ID
iv) Address

Function:
i) Login
ii) Logoff
iii) Search
iv) Add
v) Borrow
vi) Return

Staff:
Attributes:
i) Name
ii) Gender
iii) ID
iv) Address

Function:

i) Login
ii) Logoff
iii) Search
iv) Borrow
v) Return

Student:
Attributes:
i) Name
ii) Gender
iii) ID
iv) Address

Function:

i) Login
ii) Logoff
iii) Search
iv) Borrow
v) Return

4. The Object model of the digital library management system developed in ArgoUML:


//Library class
class library {
//Attributes of library class
char name[25];
char interface[50];
char space[100];
public:
// Functions of library class
int storeDetailOfData();
int add();
int search();
int Return();
int borrow();
};

// Starting of administrator class
class administrator {
// Attributes of administrator class
library name[25];
char gender[8];
int id;
char address[50];
public:
//Functions of administrator class
void login();
void logoff();
int search();
int Return();
int borrow();
};
// Starting staff class
class staff {
// Attributes of staff class
library name[25];
char gender[8];
int id;
char address[50];
public:
// Functions of staff class
void login();
void logoff();
int search();
int Return();
int borrow();
};

// starting student class
class student {
// Attributes of student class
library name[25];
char gender[8];
int id;
char address[50];
public:
//Functions of student class
void login();
void logoff();
int search();
int Return();
int borrow();
};


Implementation:


#include
using namespace std;

class Administrator
{
public:
Administrator();
Administrator(char * , char * , char *, int );

void setAdminName(char *);
char *getAdminName() const ;
void setAdminGender(char *);
char *getAdminGender() const ;
void setAdminAddress(char *);
char *getAdminAddress() const ;
void setAdminID(int);
int getAdminID()const ;

void Login();
void Logoff();
int Search(char *);
int Return(char *);
int Borrow(char *);

~Administrator();

private:

char *admin_name;
char *admin_gender;
char *admin_address;
int admin_id;
int login;
};

Administrator::Administrator()
{
login = 0; // When an object is initialized then it will be offline initially
}
Administrator::Administrator(char * _admin_name, char * _admin_gender, char *_admin_address, int _admin_id)
{
admin_name = new char[strlen(_admin_name)];
strcpy(admin_name,_admin_name);
admin_gender = new char[strlen(_admin_gender)];
strcpy(admin_gender,_admin_gender);
admin_address = new char[strlen(_admin_address)];
strcpy(admin_address,_admin_address);
admin_id = _admin_id;
login=0; // When an object is initialized then it will be offline initially
}

void Administrator::setAdminName(char * _admin_name)
{
if ( admin_name !=NULL )
{
delete []admin_name;
}
admin_name = new char[strlen(_admin_name)];
strcpy(admin_name,_admin_name);
}

char * Administrator::getAdminName() const
{
return admin_name;

}

void Administrator::setAdminGender(char * _admin_gender)
{
if (admin_gender != NULL)
{
delete []admin_gender;
}
admin_gender = new char[strlen(_admin_gender)];
strcpy(admin_gender,_admin_gender);
}

char * Administrator::getAdminGender() const
{
return admin_gender;

}

void Administrator::setAdminAddress(char * _admin_address)
{
if (admin_address != NULL)
{
delete []admin_address;
}
admin_address = new char[strlen(_admin_address)];
strcpy(admin_address,_admin_address);
}

char * Administrator::getAdminAddress() const
{
return admin_address;
}

void Administrator::setAdminID(int _admin_id )
{
admin_id = _admin_id;
}

int Administrator::getAdminID() const
{
return admin_id;
}

void Administrator::Login()
{
login = 1;
}
void Administrator::Logoff()
{
login = 0;
}

int Administrator::Search(char * b_name)
{
// Here we will Call the Libaray Class function to search the book
int found =0;
if (found)
return 1;
else
return 0;
}

int Administrator::Return(char * b_name)
{
// Here we will Call the Libaray Class function to Return the Issued book
return 1;
}

int Administrator::Borrow(char * b_name)
{
// Here we will call the Library class function to borrow the Book (issue the book)
return 1;
}

Administrator::~Administrator()
{
if (admin_address != NULL)
{
delete []admin_address;
}
if(admin_name != NULL)
{
delete []admin_name;
}
if (admin_gender != NULL)
{
delete []admin_gender;
}
}

Last updated: March 19, 2014