Guest User

Untitled

a guest
Apr 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1.  
  2.  
  3. #include <string>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7. struct Node;
  8. struct Employee;
  9. typedef Node* NodePtr;
  10. /*********************************COMPANY CLASS***********************************/
  11. class Company
  12. {
  13. private:
  14. string coName;
  15. NodePtr tp;
  16. NodePtr btm;
  17. int size;
  18. public:
  19. //constuctor
  20. Company(string name);
  21. //find employee- searches for the employee of the given name and returns a pointer to that employee's node
  22. // NOTE if the employee does not exist in the company it returns a NULL pointer!!
  23. NodePtr FindEmployee(string nm) const;
  24. //add employee given employee
  25. void AddEmployee(Employee& e);
  26. //add employee given there name and their salaryToDate (optional)
  27. void AddEmployee(string nm, double salary = 0.00);
  28. //add employee to the bottom -given a Node pointer to that employee
  29. void AddEmployee(NodePtr newEmployee);
  30. //remove employee- given the employee's name
  31. NodePtr RmEmployee(string nm);
  32. //promote employee- given the person's name
  33. void Promote(string nm);
  34. //demote employee - given the person's name
  35. void Demote(string nm);
  36. //print employee's names from top to bottom with their salaries to date
  37. void Print() const;
  38. // pay's each employee according to rank and returns total amount needed to pay employees
  39. double Payroll() const;
  40.  
  41. string name() const {return coName; }
  42. NodePtr top() const {return tp; }
  43. NodePtr bottom() const {return btm; }
  44. int sz() const {return size; }
  45. bool isEmpty() const {return (0 == size); }
  46. };
  47.  
  48.  
  49. /*************************EMPLOYEE STRUCT*****************************************/
  50. struct Employee
  51. {
  52. string name;
  53. double salaryToDate;
  54.  
  55. /*member functions*/
  56. //default constructor
  57. Employee();
  58. //paramterized constructor
  59. Employee(string name, double salary);
  60. //constant reference constructor
  61. Employee(const Employee& e);
  62. //assignment operator
  63. Employee& operator=(const Employee &e);
  64. //increments the employee's salaryToDate by rank * 1000.
  65. void PayEmployee(int rank) { salaryToDate += (1000 * rank); }
  66. };
  67.  
  68. /**************************** NODE STRUCT & MEMBER FUNCTIONS ******************************************/
  69.  
  70. struct Node
  71. {
  72. /*data members*/
  73. Employee employee;
  74. Node* superior;
  75. Node* inferior;
  76.  
  77. //constructor given employee and otional superior and inferior pointers
  78. Node(const Employee& e, Node* sup = NULL, Node* inf = NULL)
  79. {
  80. employee = e;
  81. superior = sup;
  82. inferior = inf;
  83. }
  84. //constructor given name (optional salary to date)
  85. Node(string nm, double salary = 0.00, Node* sup = NULL, Node* inf = NULL)
  86. {
  87. employee = Employee(nm, salary);
  88. superior = sup;
  89. inferior = inf;
  90. }
  91. };
Add Comment
Please, Sign In to add comment