Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iomanip>
- #include <cstdlib>
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <cstdlib>
- #include <ctime>
- #include <cctype>
- #include <fstream>
- using namespace std;
- class employee
- {
- private:
- string name;
- int idNumber;
- string department;
- string position;
- public:
- employee(string, int, string, string);
- employee(string, int);
- employee();
- void setName(string);
- void setID(int);
- void setDepartment(string);
- void setPosition(string);
- string getname() const;
- int getID() const;
- string getDepartment() const;
- string getPosition() const;
- };
- int main()
- {
- string sTemp;
- int iTemp, iEmployee;
- employee *ePtr;
- cout << "\nHow many employee would you like to add: ";
- cin >> iEmployee;
- cin.ignore();
- ePtr = new employee[iEmployee];
- for (int i = 0; i < iEmployee; i++)
- {
- cout << "\nEmployee " << i + 1 << ": \n";
- cout << "Please enter the name: ";
- getline(cin, sTemp);
- ePtr[i].setName(sTemp);
- cout << "Please enter the ID: ";
- cin >> iTemp;
- cin.ignore();
- ePtr[i].setID(iTemp);
- cout << "Please enter the department: ";
- getline(cin, sTemp);
- ePtr[i].setDepartment(sTemp);
- cout << "Please enter the position: ";
- getline(cin, sTemp);
- ePtr[i].setPosition(sTemp);
- }
- cout << "\n\n";
- cout << left << setw(20) << "Name" << setw(20) << "ID number" << setw(20) << "Deparement" << setw(20) << "Position" << endl;
- cout << "-------------------------------------------------------------------" << endl;
- for (int i = 0; i < iEmployee; i++)
- {
- cout << left << setw(20) << ePtr[i].getname() << setw(20) << ePtr[i].getID() << setw(20) << ePtr[i].getDepartment() << setw(20) << ePtr[i].getPosition();
- }
- delete[] ePtr;
- ePtr = nullptr;
- return 0;
- }
- employee::employee(string n, int id, string d, string p)
- {
- name = n;
- idNumber = id;
- department = d;
- position = p;
- }
- employee::employee(string n, int id)
- {
- name = n;
- idNumber = id;
- department = "";
- position ="";
- }
- employee::employee()
- {
- name = "";
- idNumber = 0;
- department = "";
- position = "";
- }
- string employee::getname() const
- {
- return name;
- }
- int employee::getID() const
- {
- return idNumber;
- }
- string employee::getDepartment() const
- {
- return department;
- }
- string employee::getPosition() const
- {
- return position;
- }
- void employee::setName(string n)
- {
- name = n;
- }
- void employee::setID(int id)
- {
- idNumber = id;
- }
- void employee::setDepartment(string d)
- {
- department = d;
- }
- void employee::setPosition(string p)
- {
- position = p;
- }
Advertisement
Add Comment
Please, Sign In to add comment