#include #include #include #include #include #include const unsigned int LENGTH = 5;class EmployeeList { public: typedef std::vector grades; std::map roster; std::list waiting_list; public: public: void add(const std::string& name); void remove(const std::string& name); void record(const std::string& name,const int grade,const unsigned int assignment_number); void display(); private: void newEmployee(const std::string& name) { grades no_grades; roster.insert( std::pair(name, no_grades)); }};void EmployeeList::add(const std::string& name){ if (roster.find(name) != roster.end()) return; if (roster.size() < LENGTH) { newEmployee(name); } else { waiting_list.push_back(name); }}void EmployeeList::remove(const std::string& name){ std::map::iterator anEmployee = roster.find(name); if (anEmployee == roster.end()) return; roster.erase(name); if (waiting_list.size() > 0) { std::string wait_name = waiting_list.front(); waiting_list.pop_front(); newEmployee(wait_name); }}void EmployeeList::record(const std::string& name,const int grade,const unsigned int assignment_number){ std::map::iterator anEmployee = roster.find(name); if (anEmployee == roster.end()) { std::cerr << "ERROR: No " << name << '\n'; return; } if (anEmployee->second.size() <= assignment_number) anEmployee->second.resize(assignment_number+1); anEmployee->second[assignment_number] = grade;}void EmployeeList::display(){ std::vector sorted_names; std::map::iterator curEmployee; for (curEmployee = roster.begin();curEmployee != roster.end();++curEmployee){ sorted_names.push_back(curEmployee->first); } std::sort(sorted_names.begin(), sorted_names.end()); std::vector::const_iterator cur_print; for (cur_print = sorted_names.begin();cur_print != sorted_names.end();++cur_print) { std::cout << *cur_print << '\t'; grades::const_iterator cur_grade; for (cur_grade = roster[*cur_print].begin();cur_grade != roster[*cur_print].end();++cur_grade) { std::cout << *cur_grade << ' '; } std::cout << '\n'; }}int main(){ EmployeeList empList; empList.add("A, S"); empList.add("B, M"); empList.add("J, R"); empList.add("S, J"); empList.add("M, M"); empList.add("G, W"); empList.add("C, W"); std::cout << "Before drop " << std::endl; empList.display(); std::cout << "\n"; empList.remove("J, R"); std::cout << "After drop " << std::endl; empList.display(); std::cout << "\n"; for (int i = 0; i < 5; ++i){ empList.record("A, S", i*10+50, i); empList.record("B, M", i*10+50, i); empList.record("S, J", i*10+50, i); empList.record("M, M", i*10+50, i); empList.record("G, W", i*10+50, i); } std::cout << "Final " << std::endl; empList.display(); std::cout << "\n"; return (0);} Before dropA, SB, MJ, RM, MS, JAfter dropA, SB, MG, WM, MS, JFinalA, S 50 60 70 80 90B, M 50 60 70 80 90G, W 50 60 70 80 90M, M 50 60 70 80 90S, J 50 60 70 80 90