Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- #include<cstdlib>
- #include<string>
- using namespace std;
- class person
- {
- protected:
- int id;
- string name;
- int age;
- string gender;
- public:
- void set_FieldName()
- {
- cout<<"NAME: ";
- while(!(cin>>name))
- {
- cout << "Please enter a string! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- cout<<"GENDER: ";
- while(!(cin>>gender))
- {
- cout << "Please enter a string! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- cout<<"AGE: ";
- while(!(cin>>age))
- {
- cout << "Please enter a number! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- cout<<"ID: ";
- while(!(cin>>id))
- {
- cout << "Please enter a number! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- }
- void get_fieldname()
- {
- cout<<name<<"\t\t"<<id<<"\t\t"<<gender<<"\t"<<age<<endl;
- }
- void in_name()
- {
- cout<<"NAME: ";
- cin>>name;
- }
- string get_name()
- {
- return name;
- }
- void in_id()
- {
- cout<<"ID: " ;
- cin>>id;
- }
- int get_id()
- {
- return id;
- }
- void in_gender()
- {
- cout<<"GENDER: ";
- cin>>gender;
- }
- string get_gender()
- {
- return gender;
- }
- void in_age()
- {
- cout<<"AGE: ";
- cin>>age;
- }
- int get_age()
- {
- return age;
- }
- };
- class owners: public person
- {
- private:
- double share;
- int bankacc;
- public:
- void addowner();
- void set_ownerfield()
- {
- set_FieldName();
- cout<<"SHARE: ";
- while(!(cin>>share))
- {
- cout << "Please enter a number! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- }
- void get_ownerfield()
- {
- cout<<name<<"\t\t "<<id<<"\t\t"<<gender<<"\t\t"<<age<<"\t "<<share<<endl;
- }
- void in_share()
- {
- cout<<"PERCENT OF SHARE: ";
- cin>>share;
- }
- double get_share()
- {
- return share;
- }
- void in_bankacc()
- {
- cout<<"BALANCE OF ACCOUNT: " ;
- cin>>bankacc;
- }
- int get_bankacc()
- {
- return bankacc;
- }
- };
- class manager: public person
- {
- public:
- int joiningdate;
- int salary;
- public:
- void addmanager();
- void set_managerfield()
- {
- set_FieldName();
- cout<<"salary=";
- while(!(cin>>salary))
- {
- cout << "Please enter a number! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- }
- void get_managerfield()
- {
- cout<<name<<"\t\t "<<id<<"\t\t"<<gender<<"\t\t"<<age<<"\t "<<salary<<endl;
- }
- void in_joiningdate()
- {
- cout<<"JOINING DATE AT OFFICE: ";
- cin>>joiningdate;
- }
- int get_joinigdate()
- {
- return joiningdate;
- }
- void in_salary()
- {
- cout<<"MONTHLY SALARY: " ;
- cin>>salary;
- }
- int get_salary()
- {
- return salary;
- }
- };
- class salesman: public person
- {
- private:
- double salary;
- int joiningdate;
- public:
- void addsalesman();
- void set_salesmanfield()
- {
- set_FieldName();
- cout<<"SALARY: ";
- while(!(cin>>salary))
- {
- cout << "Please enter a number! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- cout<<"JOININGDATE: ";
- while(!(cin>>joiningdate))
- {
- cout << "Please enter a number! Try again: ";
- cin.clear ();
- cin.ignore (1000, '\n');
- }
- }
- void get_salesmanfield()
- {
- cout<<name<<"\t\t "<<id<<"\t\t"<<gender<<"\t\t"<<age<<"\t "<<salary<<"\t "<<joiningdate<<endl;
- }
- void in_salary()
- {
- cin>>salary;
- }
- double get_salary()
- {
- return salary;
- }
- void in_joiningdate()
- {
- cin>>joiningdate;
- }
- int get_joinigdate()
- {
- return joiningdate;
- }
- };
- void:: owners::addowner()
- {
- int b;
- char redo;
- do{
- int i;
- int n=0;
- n++;
- set_ownerfield();
- cout<<"\nOwner information has been added:"<<endl;
- cout<<"\n name id gender age share\n";
- cout<<"\n------- ------- -------- ------- ------\n";
- for(i=0;i<n;i++)
- {
- get_ownerfield();
- }
- cout<<"do you want to add another:"<<endl;
- cin>>redo;
- }
- while(redo=='y'||redo=='Y')
- ;}
- void::manager::addmanager()
- {
- int i=0;
- char redo;
- do{
- int n=0;
- n++;
- set_managerfield();
- cout<<"\nmanager information has been added:"<<endl;
- cout<<"\n name id gender age salary \n"<<endl;
- cout<<"\n---------- --------- -------- ------- -------- \n"<<endl;
- // cout<<e[i].get_fieldname()<<endl;
- for(int i=0;i<n;i++){
- get_managerfield();
- }
- cout<<"do you want to add another:"<<endl;
- cin>>redo;
- }
- while(redo=='y'||redo=='Y')
- ;}
- void::salesman::addsalesman()
- {
- int i=0;
- char redo;
- do{
- int n=0;
- n++;
- set_salesmanfield();
- cout<<"\nsalesman information has been added:"<<endl;
- cout<<"\n name id gender age salary joiningdate \n"<<endl;
- cout<<"\n---------- ----- -------- ------- -------- --------- \n"<<endl;
- // cout<<e[i].get_fieldname()<<endl;
- for(int i=0;i<n;i++){
- get_salesmanfield();
- }
- cout<<"do you want to add another:"<<endl;
- cin>>redo;
- }
- while(redo=='y'||redo=='Y')
- ;}
- class product
- {
- private:
- int id;
- string name;
- double price;
- string brand;
- public:
- void in_id()
- {
- cout<<"product identity: ";
- cin>>id;
- }
- int get_id()
- {
- return id;
- }
- void in_name()
- {
- cout<<"Enter the product name: ";
- cin>>name;
- }
- string get_name()
- {
- return name;
- }
- void in_price()
- {
- cout<<"price of product: ";
- cin>>price;
- }
- double get_price()
- {
- return price;
- }
- void in_brand()
- {
- cout<<"Brand of product: ";
- cin>>brand;
- }
- string get_brand()
- {
- return brand;
- }
- };
- class food: public product
- {
- private:
- double expdate;
- double quantity;
- public:
- void addfood();
- void in_expdate()
- {
- cout<<"Enter the product expdate: ";
- cin>>expdate;
- }
- double get_expdate()
- {
- return expdate;
- }
- void in_quantity()
- {
- cout<<"Enter the product quantity: ";
- cin>>quantity;
- }
- double get_quantity()
- {
- return quantity;
- }
- };
- class cosmetics: public product
- {
- private:
- double expdate;
- double quantity;
- public:
- void in_expdate()
- {
- cout<<"Enter the product expdate: ";
- cin>>expdate;
- }
- double get_expdate()
- {
- return expdate;
- }
- void in_quantity()
- {
- cout<<"Enter the product quantity: ";
- cin>>quantity;
- }
- double get_quantity()
- {
- return quantity;
- }
- };
- void::food::addfood()
- {
- int i=0;
- cout<<"\nFood information has been added:"<<endl;
- cout<<"\n name id price brand \n";
- cout<<"\n------- ------- -------- ------- \n";
- }
- int main()
- {
- owners obj1[5];
- manager obj2[5];
- salesman obj3[5];
- int c;
- char operation,ch;
- do
- {
- cout<<"who do you want to know about?\n"<<endl;
- cout<<endl;
- cout<<endl;
- cout<<" 1. About Owner"<<endl;
- cout<<" 2. About Manager"<<endl;
- cout<<" 3. About Salesman"<<endl;
- cout<<" 4. About product"<<endl;
- cout<<endl;
- cout<<"Enter the Serial number you desire: ";
- cin>>c;
- if(c==1)
- {
- int x;
- char redo;
- {
- int o;
- cout<<"\nOwner information"<<endl;
- cout<<endl;
- cout<<"1.Add owner"<<endl;
- cout<<"2.Delete owner"<<endl;
- cout<<endl;
- cout<<"enter choice: ";
- cin>>o;
- if(o==1)
- {
- cout<<"Enter the information of the owner:"<<endl;
- for(int i=0;i<5;i++)
- {
- obj1[i].addowner();
- }
- }
- else if(o==2)
- {
- cout<<"Delete information of owner"<<endl;
- }
- }
- }
- else if(c==2)
- {
- int m;
- cout<<"\nManager information"<<endl;
- cout<<endl;
- cout<<"1.Add manager"<<endl;
- cout<<"2.Delete manager"<<endl;
- cout<<endl;
- cout<<"enter choice: "<<endl;
- cin>>m;
- if(m==1)
- {
- cout<<"Add manager information"<<endl;
- for(int i=0;i<5;i++)
- {
- obj2[i].addmanager();
- }
- }
- else if(m==2)
- {
- cout<<"Delete information manager"<<endl;
- }
- }
- else if(c==3)
- {
- cout<<"\nSalesman Information"<<endl;
- int s;
- cout<<endl;
- cout<<"1.Add Salesman"<<endl;
- cout<<"2.Delete Salesman"<<endl;
- cout<<endl;
- cout<<"enter choice: "<<endl;
- cin>>s;
- if(s==1)
- {
- cout<<"Add salesman information"<<endl;
- for(int i=0;i<5;i++)
- {
- obj3[i].addsalesman();
- }
- }
- else if(s==2)
- {
- cout<<"delete information of salesman"<<endl;
- }
- }
- else if(c==4)
- {
- int p;
- cout<<"\nProduct information"<<endl;
- cout<<endl;
- cout<<"1.About Food"<<endl;
- cout<<"2. About Electronics"<<endl;
- cout<<"3.About cosmetics"<<endl;
- cout<<endl;
- cout<<"enter choice: "<<endl;
- cin>>p;
- if(p==1)
- {
- cout<<"\nFood information"<<endl;
- cout<<"1.Add food"<<endl;
- cout<<"2.Delete food"<<endl;
- }
- if(p==2)
- {
- cout<<"\nElectronics information"<<endl;
- cout<<"1.Add Electronics"<<endl;
- cout<<"2.Delete Electronics"<<endl;
- }
- if(p==3)
- {
- cout<<"\nCosmetics information"<<endl;
- cout<<"1.Add Cosmetics"<<endl;
- cout<<"2.Delete Cosmetics"<<endl;
- }
- }
- cout<<"\nDo u want to continue ";
- cin>>ch;
- }
- while(ch=='y'||ch=='Y')
- ;return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement