Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string.h>
- #include <cstring>
- using namespace std;
- class menu {
- private:
- int optn;
- public:
- void menuOptn () {
- // ........................................menu start......................................................................//
- cout<<endl;
- cout<<endl;
- cout<<endl;
- cout<<" "<<"***********************************************************************************"<<endl;
- cout<<" "<<"* "<<" *"<<endl;
- cout<<" "<<"* "<<"1. Enter new user"<<" *"<<endl;
- cout<<" "<<"* "<<" *"<<endl;
- cout<<" "<<"* "<<"2. search user from ID"<<" *"<<endl;
- cout<<" "<<"* "<<" *"<<endl;
- cout<<" "<<"* "<<"3. print all user data"<<" *"<<endl;
- cout<<" "<<"* "<<" *"<<endl;
- cout<<" "<<"* "<<"4. delete user by ID"<<" *"<<endl;
- cout<<" "<<"* "<<" *"<<endl;
- cout<<" "<<"* "<<"5. close program"<<" *"<<endl;
- cout<<" "<<"* "<<" *"<<endl;
- cout<<" "<<"***********************************************************************************"<<endl;
- // ........................................menu end.....................................................................//
- }
- };
- class employee {
- protected:
- vector<int> empId;
- vector<string>empName;
- vector<string>empPost;
- vector<string>empSalary;
- public:
- void setVectorInitialValue () {
- string nameArr[4] = {"C111","C112","C113","C114"};
- string postArr[4] = {"A111","A112","A113","A114"};
- string salaryArr[4]= {"B111","B112","B113","B114"};
- int idArr[4] = {111, 112,113,114};
- empId.assign(idArr, idArr+4);
- empName.assign(nameArr, nameArr+4);
- empPost.assign(postArr, postArr+4);
- empSalary.assign(salaryArr, salaryArr+4);
- }
- void setEmpId (int id) {
- empId.push_back(id);
- }
- void setEmpName (string name) {
- empName.push_back(name);
- }
- void setEmpPOst (string post) {
- empPost.push_back(post);
- }
- void setEmpSalary (string salary) {
- empSalary.push_back(salary);
- }
- void display() {
- int sIze = empId.size();
- for (int i=0; i<sIze ;i++) {
- cout<<"ID: "<<empId[i]<<" "<<"NAME: "<<" "<<empName[i]<<" "<<"POST: "<<" "<<empPost[i]<<" "<<"SALARY: "<<empSalary[i]<<endl;
- }
- }
- void test () {
- cout << empId[1];
- }
- };
- /* class searchEmp:public employee {
- private:
- int usrID;
- public:
- void setUsrId ( int m_usrId) {
- usrID = m_usrId;
- }
- void display() {
- cout<<empName[1];
- int sIze = empId.size();
- for (int i=0; i<sIze ;i++) {
- if (usrID == empId[i])
- cout<<"ID: "<<empId[i]<<" "<<"NAME: "<<" "<<empName[i]<<" "<<"POST: "<<" "<<empPost[i]<<" "<<"SALARY: "<<empSalary[i]<<endl;
- //break;
- }
- }
- };
- class fireEmp:public employee {
- private:
- int usrID;
- public:
- void setUsrID (int m_usrid) {
- usrID = m_usrid;
- }
- void display() {
- int sIze = empId.size();
- for (int i=0; i<sIze ;i++) {
- if (empId[i]==usrID) {
- empId.erase(empId.begin() +i);
- empName.erase(empName.begin() +i);
- empPost.erase(empPost.begin() +i);
- empSalary.erase(empSalary.begin() +i);
- break;
- }
- }
- }
- };
- */
- int getUsrChoice () {
- int usrChoice;
- cout<< "ENTER THE NUMBER OF THE OPTION YOU WANT TO PICK: "<<endl;
- cin>> usrChoice;
- return usrChoice;
- }
- int main () {
- int tempId; string tempName; string tempPost; string tempSalary;
- menu m1; employee *e1, e2;
- //searchEmp s1; fireEmp f1;
- e2.setVectorInitialValue();
- m1.menuOptn();
- //-------- user choice -------//
- if(getUsrChoice()== 1) {
- cout<<"ID: "; cin >> tempId;
- cout<<"NAME: "; cin >>tempName;
- cout<<"POST: "; cin >> tempPost;
- cout<<"SALARY: "; cin >> tempSalary; cout<<endl;
- e2.setEmpId(tempId);
- e2.setEmpName(tempName);
- e2.setEmpPOst(tempPost);
- e2.setEmpSalary(tempSalary);
- }
- if (getUsrChoice() == 2) {
- cout<<"ENTER USER ID: "; cin >> tempId;
- //s1.setUsrId(tempId);
- //s1.display();
- e2.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement