Skip to content

Instantly share code, notes, and snippets.

@somratcste
Created September 30, 2013 19:08
Show Gist options
  • Save somratcste/6768569 to your computer and use it in GitHub Desktop.
Save somratcste/6768569 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
class books
{
char aname[20];
char tname[20];
char *author[4];
char *title[4];
char *price[4];
char *publisher[4];
char *stock[4];
char ch;
public :
void showlist();
void order();
};
void books::showlist()
{
int i;
char *author[4]={"kazinazrul","rabindranath","promothchow.","sufiakamal"};
char *title[4]={"bindhasagor","seserkabita","biserbina","chototori"};
char *price[4]={"100","200","300","400"};
char *publisher[4]={"mina","raju","kabir","rahim"};
char *stock[4]={"5","10","15","20"};
cout<<endl<<endl<<endl<<'\t'<<"Author"<<'\t'<<'\t'<<"Title"<<'\t'<<'\t'<<"Price"<<'\t'<<"Publisher"<<'\t'<<"Stock"<<endl;
cout<<'\t'<<"--------------------------------------------------------------"<<endl<<endl;
for(i=0;i<4;i++)
{
cout<<'\t'<<author[i]<<'\t'<<title[i]<<'\t'<<price[i]<<'\t'<<publisher[i]<<'\t'<<'\t'<<stock[i]<<endl<<endl;
}
}
void books::order()
{
books ob;
int i;
cout<<endl<<endl<<"Are you sure want to order our books(y/n) ?";
cin>>ch;
if(ch=='Y' || ch=='y')
{
cout<<"Thank you very much to choice our products."<<endl;
cout<<endl<<"Pls enter your Books Author name : "<<endl;
cin>>ob.aname;
cout<<endl<<"And Then enter your Books Title name : "<<endl;
cin>>ob.tname;
for(i=0;i<4;i++)
{
if((strcmp(ob.aname,ob.author[i])==0) && (strcmp(ob.tname,ob.title[i])==0) )
{
cout<<endl<<"This Books are available in ours Shops."<<endl;
}
}
}
}
int main()
{
books o;
while(true)
{
int index;
cout<<endl<<endl<<"What do you want : "<<endl;
cout<<"1 for see booklist"<<endl<<"2 for Order"<<endl;
cout<<"3 for Exit the program"<<endl;
cin>>index;
switch(index)
{
case 1:
o.showlist();
break;
case 2:
o.order();
break;
default :
cout<<endl<<endl<<"Many many thanks to perform this operation"<<endl<<endl;
return 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment