Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- struct Node;
- struct Employee;
- typedef Node* NodePtr;
- /*********************************COMPANY CLASS***********************************/
- class Company
- {
- private:
- string coName;
- NodePtr tp;
- NodePtr btm;
- int size;
- public:
- //constuctor
- Company(string name);
- //find employee- searches for the employee of the given name and returns a pointer to that employee's node
- // NOTE if the employee does not exist in the company it returns a NULL pointer!!
- NodePtr FindEmployee(string nm) const;
- //add employee given employee
- void AddEmployee(Employee& e);
- //add employee given there name and their salaryToDate (optional)
- void AddEmployee(string nm, double salary = 0.00);
- //add employee to the bottom -given a Node pointer to that employee
- void AddEmployee(NodePtr newEmployee);
- //remove employee- given the employee's name
- NodePtr RmEmployee(string nm);
- //promote employee- given the person's name
- void Promote(string nm);
- //demote employee - given the person's name
- void Demote(string nm);
- //print employee's names from top to bottom with their salaries to date
- void Print() const;
- // pay's each employee according to rank and returns total amount needed to pay employees
- double Payroll() const;
- string name() const {return coName; }
- NodePtr top() const {return tp; }
- NodePtr bottom() const {return btm; }
- int sz() const {return size; }
- bool isEmpty() const {return (0 == size); }
- };
- /*************************EMPLOYEE STRUCT*****************************************/
- struct Employee
- {
- string name;
- double salaryToDate;
- /*member functions*/
- //default constructor
- Employee();
- //paramterized constructor
- Employee(string name, double salary);
- //constant reference constructor
- Employee(const Employee& e);
- //assignment operator
- Employee& operator=(const Employee &e);
- //increments the employee's salaryToDate by rank * 1000.
- void PayEmployee(int rank) { salaryToDate += (1000 * rank); }
- };
- /**************************** NODE STRUCT & MEMBER FUNCTIONS ******************************************/
- struct Node
- {
- /*data members*/
- Employee employee;
- Node* superior;
- Node* inferior;
- //constructor given employee and otional superior and inferior pointers
- Node(const Employee& e, Node* sup = NULL, Node* inf = NULL)
- {
- employee = e;
- superior = sup;
- inferior = inf;
- }
- //constructor given name (optional salary to date)
- Node(string nm, double salary = 0.00, Node* sup = NULL, Node* inf = NULL)
- {
- employee = Employee(nm, salary);
- superior = sup;
- inferior = inf;
- }
- };
Add Comment
Please, Sign In to add comment