using namespace std;
//***************************************************** Global variable******************************
int inc=0;
//***************************************************** Class book***********************************
class book
{
//system("color 4E");
public:
int bookcode;
char bookname[20];
char authorname[20];
char bookpub[20];
int bookprice;
int status;
public:
void addbook()
{
status=1;
cout<<"\t\t\t YOU HAVE CHOSEN TO ADD BOOK DETAILS"<<endl;
cout<<"\t\t\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<endl;
inc++;
bookcode=100+inc;
cout<<"\n\tBook code :"<<bookcode;
cout<<endl;
cout<<"\n\tEnter book name :";
cin>>bookname;
cout<<"\n\tEnter author name :";
cin>>authorname;
cout<<"\n\tEnter publishing company :";
cin>>bookpub;
cout<<"\n\tEnter book price :";
cin>>bookprice;
}
};
//*************************************************************************************************************
//***************************************************** Class student *****************************************
class student
{
public:
int ip;
char studentname [20];
char departementname [20];
char bookname[20];
int bookcode;
int dateborrow;
public:
void addstudent()
{
cout<<"\n\n\t YOU HAVE CHOSEN TO ADD student DETAILS for borrow book"<<endl;
cout<<"\t\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<endl;
cout<<"\n\tStudent ID code :";
cin>> ip;
cout<<"\n\tEnter book name :";
cin>>bookname;
cout<<"\n\tEnter the student name :";
cin>> studentname;
cout<<"\n\tEnter the date borrow :";
cin>>dateborrow;
}
};
//**********************************************************************************************************
//***************************************************** Class Lecture *****************************************
class lecture
{
public:
int ip;
char Lecturename [20];
char departementname [20];
int bookcode;
public:
void addLecture ()
{
}
};
//***********************************************************************************************************
//***************************************************** Class Librarian *****************************************
class Librarian
{
public:
int ip;
char Librarianname [20];
char departementname [20];
int bookcode;
//***************************************************** int main *******************************************
void main()
{
system("color 4E");
char username [12];
cout<<"\n\n Welcome to the library system. "<<endl;
cout<<"\n\n To login, if you are a lecturer, you should write 'lecture'. "<<endl;
cout<<"\n\n To login, if you are a student, you should write 'student'. "<<endl;
cout<<"\n\n To login, if you are a Librarian, you should write 'Librarian'."<<endl;
cout<<"\n\n To login, if you wanna add books, you should write 'book'. "<<endl;
cin>> username;
if (username == "book")
{
book a,
addbook();
}
else if (username == "student")
{
student b,
addstudent();
}
else if (username == "lecture")
{
lecture c,
addLecture();
}
and one more thing, currently the username will not match with any of the if conditions because the size of the array is 12 and it will be padded with some characters in the front. so preferrably use string for that.
string username;
getline(cin, username); //instead of cin >> username;