March 2, 2012

Practically implementing Object oriented concepts using c++

Practically implementing Object oriented concepts using c++

(Download Code)
#include
#include
#include “mc100200752_CS304_5.h”

//mc100200752

//START – DEFINITION OF administrator FUNCTIONS
bool administrator::login()
{
//we will compare this id with our library DBMS records
//if user exists then
is_login = true;
return is_login;
};
bool administrator::logoff(int id)
{
};
int administrator::search()
{
};
int administrator::Return()
{
};
int administrator::borrow()
{

printf(“Record updated successfully.”);
return 1;

};
administrator::~administrator()
{
if(name != NULL) delete []name;
if (gender != NULL) delete []gender;
if (address != NULL) delete []address;
}
//END – DEFINITION OF administrator FUNCTIONS

//START – DEFINITION OF staff FUNCTIONS
bool staff::login()
{
//we will compare this id with our library DBMS records
//if user exists then
is_login = true;
return is_login;
};
bool staff::logoff(int id)
{
};
int staff::search()
{
};
int staff::Return()
{
};
int staff::borrow()
{

printf(“Record updated successfully.”);
return 1;

};
staff::~staff()
{
if(name != NULL) delete []name;
if (gender != NULL) delete []gender;
if (address != NULL) delete []address;
}
//END – DEFINITION OF staff FUNCTIONS

//START – DEFINITION OF student FUNCTIONS
bool student::login(int id)
{

//we will compare this id with our library DBMS records
//if user exists then
is_login = true;
return is_login;
};
bool student::logoff(int id)
{
//logoff current logged in user
};
char student::search()
{
//searching
};
void student::Return(void)
{
printf(“Record updated successfully.”);

};
int student::borrow()
{
printf(“Record updated successfully.”);
return 1;

};
student::~student()
{
if(name != NULL) delete []name;
if (gender != NULL) delete []gender;
if (address != NULL) delete []address;
};
//END – DEFINITION OF student FUNCTIONS

using namespace std;

int main(int argc, char *argv[])
{

int option_for_user_type;
int id, select_option;
char book_title, confirm_borrow, return_id;

cout << “____________________________________________________________________________\n”;
cout << “How it works?\n”;
cout << “____________________________________________________________________________\n”;
cout << “1- Get user input for user type\n”;
cout << “2- Get user input for user id\n”;
cout << “3- Offers options to operate library\n\n”;
cout << “Note: Classes, attributes, functions are declared in .h file. Then initialized in .cpp file. Then all classes are aggregated with in library class. We offer library operations to user and facilitate him with library object. \n\nImportant: Aggregation facilicated us to peform all requried functions through library class object instead of creating multiple objects.\n”;
cout << “____________________________________________________________________________\n”;

cout << “Please select options\n\n”;
cout << “1- For Student\n”;
cout << “2- For Adminstator\n”;
cout << “3- For Staff\n\n\n”;
cout << “Enter: “; cin>>option_for_user_type;

cout << “\n\nPlease enter your ID: “; cin >> id;

//OBJECT DECLARATION & INITIALIZATION
library obj_lib;

cout << “\n\t\t\t\tWelcome\n”;
cout << “____________________________________________________________________________\n”;
cout << “____________________________________________________________________________”;
cout << “\n\nSelect Options:\n\n”;
cout << “1- Search\n”;
cout << “2- Borrow\n”;
cout << “3- Return\n”;
cout << “4- Logoff\n”;
cout << “\nEnter: “; cin >> select_option;

//FUNCTIONS
switch(select_option)
{
case 1:

cout << “This is quick search utility\n”;
cout << “Please enter book title: “; cin >> book_title;

obj_lib.search();

break;

case 2:

cout << “\nPlease confirm that you want to borrow this book? (Y/N): “; cin >> confirm_borrow;

obj_lib.borrow(option_for_user_type);

break;

case 3:

cout << “\nPlease enter your book ID to return: “; cin >> return_id;
obj_lib.Return();

break;

case 4:

obj_lib.logoff(option_for_user_type,id);

break;

}

cout << “\n\nThank You!\n\n”; system(“PAUSE”); return EXIT_SUCCESS; } //START – DEFINITION OF library FUNCTIONS int library::storeDetailOfData() { }; int library::add() { }; int library::search() { printf(“\nSearching…\n\n”); printf(“\nNo results found.\n\n”); }; int library::Return() { }; int library::borrow(int value) { switch (value) { case 1: obj_student->borrow();

break;

case 2:
obj_admin->borrow();
break;

case 3:

obj_staff->borrow();

break;
}

};

bool library::logoff(int value,int id)
{

switch (value)
{

case 1:

return obj_student->logoff(id);

break;

case 2:

return obj_admin->logoff(id);

break;

case 3:

return obj_staff->logoff(id);

break;
}

};
library::~library()
{
if(name != NULL) delete []name;
if (interface != NULL) delete []interface;
if (space != NULL) delete []space;
}

//END – DEFINITION OF library FUNCTIONS


Included File: mc100200752_CS304_5.h


// Starting of administrator class
class administrator {
private:

// Attributes of administrator class
char name[25];
char gender[8];
int id;
char address[50];
char * book_title;
bool is_login;

public:
//Functions of administrator class
bool login();
bool logoff(int);
int search();
int Return();
int borrow();
~administrator();
};
// Starting staff class
class staff {

private:

// Attributes of staff class
char name[25];
char gender[8];
int id;
char address[50];
char * book_title;
bool is_login;

public:
// Functions of staff class
bool login();
bool logoff(int);
int search();
int Return();
int borrow();
~staff();
};

// starting student class
class student {

private:

// Attributes of student class
char * name;
char * gender;
char * id;
char * address;
char * book_title;
bool is_login;

public:

student()
{
is_login = false;

}

//Functions of student class
void signup();
bool login(int);
bool logoff(int);
char search();
void Return(void);
int borrow();
~student();
};

//Library class
class library {

private:

student * obj_student;
administrator * obj_admin;
staff * obj_staff;

//Attributes of library class
char name[25];
char interface[50];
char space[100];

//mc100200752

public:

library()
{
staff();
student();
administrator();

}

// Functions of library class
int storeDetailOfData();
int add();
int search();
int Return();
bool logoff(int,int);
int borrow(int);
~library();
};

Last updated: March 19, 2014