Caeg

Untitled

Apr 21st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <iostream>
  5. #include <string>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <cstdlib>
  9. #include <ctime>
  10. #include <cctype>
  11. #include <fstream>
  12.  
  13.  
  14.  
  15. using namespace std;
  16.  
  17.  
  18.  
  19. class employee
  20.  
  21. {
  22. private:
  23. string name;
  24. int idNumber;
  25. string department;
  26. string position;
  27.  
  28. public:
  29. employee(string, int, string, string);
  30. employee(string, int);
  31. employee();
  32.  
  33.  
  34. void setName(string);
  35. void setID(int);
  36. void setDepartment(string);
  37. void setPosition(string);
  38.  
  39. string getname() const;
  40. int getID() const;
  41. string getDepartment() const;
  42. string getPosition() const;
  43.  
  44. };
  45.  
  46. int main()
  47. {
  48. string sTemp;
  49. int iTemp, iEmployee;
  50. employee *ePtr;
  51.  
  52. cout << "\nHow many employee would you like to add: ";
  53. cin >> iEmployee;
  54. cin.ignore();
  55.  
  56. ePtr = new employee[iEmployee];
  57.  
  58. for (int i = 0; i < iEmployee; i++)
  59. {
  60. cout << "\nEmployee " << i + 1 << ": \n";
  61. cout << "Please enter the name: ";
  62. getline(cin, sTemp);
  63. ePtr[i].setName(sTemp);
  64.  
  65. cout << "Please enter the ID: ";
  66. cin >> iTemp;
  67. cin.ignore();
  68. ePtr[i].setID(iTemp);
  69.  
  70. cout << "Please enter the department: ";
  71. getline(cin, sTemp);
  72. ePtr[i].setDepartment(sTemp);
  73.  
  74. cout << "Please enter the position: ";
  75. getline(cin, sTemp);
  76. ePtr[i].setPosition(sTemp);
  77.  
  78. }
  79.  
  80. cout << "\n\n";
  81.  
  82. cout << left << setw(20) << "Name" << setw(20) << "ID number" << setw(20) << "Deparement" << setw(20) << "Position" << endl;
  83.  
  84. cout << "-------------------------------------------------------------------" << endl;
  85.  
  86. for (int i = 0; i < iEmployee; i++)
  87. {
  88. cout << left << setw(20) << ePtr[i].getname() << setw(20) << ePtr[i].getID() << setw(20) << ePtr[i].getDepartment() << setw(20) << ePtr[i].getPosition();
  89. }
  90. delete[] ePtr;
  91. ePtr = nullptr;
  92. return 0;
  93. }
  94.  
  95. employee::employee(string n, int id, string d, string p)
  96. {
  97. name = n;
  98. idNumber = id;
  99. department = d;
  100. position = p;
  101. }
  102.  
  103. employee::employee(string n, int id)
  104. {
  105. name = n;
  106. idNumber = id;
  107. department = "";
  108. position ="";
  109. }
  110.  
  111. employee::employee()
  112. {
  113. name = "";
  114. idNumber = 0;
  115. department = "";
  116. position = "";
  117. }
  118.  
  119. string employee::getname() const
  120. {
  121. return name;
  122. }
  123.  
  124. int employee::getID() const
  125. {
  126. return idNumber;
  127. }
  128.  
  129. string employee::getDepartment() const
  130. {
  131. return department;
  132. }
  133.  
  134.  
  135. string employee::getPosition() const
  136. {
  137. return position;
  138. }
  139.  
  140.  
  141.  
  142. void employee::setName(string n)
  143. {
  144. name = n;
  145.  
  146. }
  147.  
  148. void employee::setID(int id)
  149. {
  150. idNumber = id;
  151. }
  152.  
  153. void employee::setDepartment(string d)
  154. {
  155. department = d;
  156. }
  157.  
  158. void employee::setPosition(string p)
  159. {
  160. position = p;
  161. }
Advertisement
Add Comment
Please, Sign In to add comment