Question I don't think I Was being super specific with my last question about this as im still having trouble with this concept. Given a set list of names (12 of them) I need to create an employment management application for this fictional company where I am to put 3 attributes: name, age, and position. Here's the list: Name Age Position Michael 45 Manager Dwight 40 Assistant to Manager Jim 35 Manager Pam 30 Receptionist Angela 32 Accountant Kevin 42 Accountant Oscar 40 Accountant Stanely 55 Salesperson Phyllis 45 Salesperson Andy 38 Salesperson Ryan 30 Salesperson Creed 55 Salesperson
I don't think I Was being super specific with my last question about this as im still having trouble with this concept.
Given a set list of names (12 of them) I need to create an employment management application for this fictional company where I am to put 3 attributes: name, age, and position.
Here's the list:
Name | Age | Position |
Michael | 45 | Manager |
Dwight | 40 |
Assistant to Manager
|
Jim | 35 |
Manager |
Pam | 30 | Receptionist |
Angela | 32 | Accountant |
Kevin | 42 | Accountant |
Oscar | 40 | Accountant |
Stanely | 55 | Salesperson |
Phyllis | 45 | Salesperson |
Andy | 38 | Salesperson |
Ryan | 30 | Salesperson |
Creed | 55 | Salesperson |
These are the steps involved in this project:
1. First, you will display information about all employees in the company.
2. Next, you will use the Position attribute for each employee to assign employees to either of these three departments: Management, Sales or Accounts. Note that if the position attribute of an employee contains the word “Manager”, s/he will be assigned to the department “Management”. If the position contains the word “Salesperson”, s/he will be assigned to the department “Sales”. If the position contains the words “Accountant”, s/he will be assigned to the department “Accounts”. Note that there may be employees in the company who are not assigned to any of these three departments.
3. You will now display the employee information in each department. You will do this for all three departments (A sample output can be seen at the end of this document).
4. Next, for each department, you will assign one or more department heads. This assignment should be made based on the employee age. The oldest employee in each department should be made the head of that department and their position attribute must be changed to reflect this (for example “Accountant” changes to “Head Accountant”). If one or more employees have the same age and are the oldest in the department, all of them should be made the heads of the department.
5. Finally, you will again display the employee information in each department for all three departments that reflects the new position assignments.
Tasks:
1. Create an employee class that represents employees of Dunder Mifflin.
2. Create 12 employee objects and add them to an employee list. Define and call a function named display_employees() that takes this list as argument and displays information regarding the employee name, age and position. You must use a loop inside this function.
3. Define and call another function named allocate_department() that accepts the employee list as argument. This function allocates employees to the three departments as described earlier and returns a single list containing this information (each item in this list is in itself a list that contains employees assigned to individual departments). You must either use list comprehension or a loop inside this function.
4. Define and call a function named display_department_employees() that takes the list returned from allocate_department() as its only argument and displays employee information for each department. You must use a loop inside this function.
5. Define and call another function named head_of_department() that takes the list returned from allocate_department() as its only argument and alters this list to assign department heads according to the criteria described earlier. This function should change the position attribute(s) of the department head(s) for each department within this list and return nothing. You must use a loop inside this function.
6. Finally, call the display_department_employees() function again to display the employee information for all departments after the head of the department is assigned to each department.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images