int main() { std::cout << "Creating two employees:" << std::endl; Employee employee1("Billy Boss", "CEO", 21000000); std::cout << "Billy Boss title is CEO. His Salary is 21000000." << std::endl; Employee employee2("Helen Hackmiester", "Engineer", 100000); std::cout << "Helen Hackmiester is an Engineer. Her Salary is 100000." << std::endl; std::cout << "Creating two departments:" << std::endl; //Payroll accounting(); //Payroll* payroll = &accounting; Payroll* payroll = new Payroll(); //Personnel HR(); //Personnel* personnel = &HR; Personnel* personnel = new Personnel(); std::cout << "Adding departments as observers of empoyees:" << std::endl; employee1.add_observer(payroll); employee1.add_observer(personnel); employee2.add_observer(payroll); employee2.add_observer(personnel); std::cout << "Changing Billy Boss' salary:" << std::endl; employee1.setSalary(30000000); std::cout << "Changing Helen Hackmiester's title:" << std::endl; employee2.setTitle("Sr. Engineer"); delete payroll; delete personnel; return 0; }
int main() { cout<<"Create employee1!"<<endl; Employee employee1("obama", "black", 100); int salary1 = employee1.getSalary(); cout<<"The firstname is "<<employee1.getFirstname()<<endl; cout<<"The lastname is "<<employee1.getLastname()<<endl; cout<<"The monthly salary is "<<salary1<<endl; cout<<"The yearly salary is "<<12*salary1<<endl; cout<<"After given a 10 percent raise, "; employee1.setSalary(salary1*1.1); salary1 = employee1.getSalary(); cout<<"The yearly salary is "<<12*salary1<<endl<<endl; cout<<"Create employee2!"<<endl; Employee employee2("Jinping", "Xi", 200); int salary2 = employee2.getSalary(); cout<<"The firstname is "<<employee2.getFirstname()<<endl; cout<<"The lastname is "<<employee2.getLastname()<<endl; cout<<"The monthly salary is "<<salary2<<endl; cout<<"The yearly salary is "<<12*salary2<<endl; cout<<"After given a 10 percent raise, "; employee2.setSalary(salary2*1.1); salary2 = employee2.getSalary(); cout<<"The yearly salary is "<<12*salary2<<endl<<endl; return 0; }