01: #include <string>
02: #include <iostream>
03:
04: using namespace std;
05:
06: #include "ccc_empl.h"
07:
08: /**
09: A department in an organization.
10: */
11: class Department
12: {
13: public:
14: Department(string n);
15: void set_receptionist(Employee* e);
16: void set_secretary(Employee* e);
17: void print() const;
18: private:
19: string name;
20: Employee* receptionist;
21: Employee* secretary;
22: };
23:
24: /**
25: Constructs a department with a given name.
26: @param n the department name
27: */
28: Department::Department(string n)
29: {
30: name = n;
31: receptionist = NULL;
32: secretary = NULL;
33: }
34:
35: /**
36: Sets the receptionist for this department.
37: @param e the receptionist
38: */
39: void Department::set_receptionist(Employee* e)
40: {
41: receptionist = e;
42: }
43:
44: /**
45: Sets the secretary for this department.
46: @param e the secretary
47: */
48: void Department::set_secretary(Employee* e)
49: {
50: secretary = e;
51: }
52:
53: /**
54: Prints a description of this department.
55: */
56: void Department::print() const
57: {
58: cout << "Name: " << name << "\n"
59: << "Receptionist: ";
60: if (receptionist == NULL)
61: cout << "None";
62: else
63: cout << receptionist->get_name() << " "
64: << receptionist->get_salary();
65: cout << "\nSecretary: ";
66: if (secretary == NULL)
67: cout << "None";
68: else if (secretary == receptionist)
69: cout << "Same";
70: else
71: cout << secretary->get_name() << " "
72: << secretary->get_salary();
73: cout << "\n";
74: }
75:
76: int main()
77: {
78: Department shipping("Shipping");
79: Department qc("Quality Control");
80: Employee* harry = new Employee("Hacker, Harry", 45000);
81: shipping.set_secretary(harry);
82: Employee* tina = new Employee("Tester, Tina", 50000);
83: qc.set_receptionist(tina);
84: qc.set_secretary(tina);
85: tina->set_salary(55000);
86: shipping.print();
87: qc.print();
88:
89: return 0;
90: }