Learning Outcomes 1. Implement derived classes using inheritance 2. Utilize the protected modifier and base constructors...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Learning Outcomes 1. Implement derived classes using inheritance 2. Utilize the protected modifier and base constructors 3. Implement polymorphism Program Overview In this program, you will create a data list of Employees. Each Employee has a name & and ID. Managers must also be part of this data list. A manager is an employee as well. However, in addition to managers having all the characteristics of employees, managers also manage employees as subordinates. Therefore, a Manager has a list of Employees they manage as well as a count of how many subordinates they have. Your application should ask the user for details to maintain the list of employees. For each employee, the program should ask the user for the name and whether or not the employee is a manager. If the user specifies that the employee is a Manager, the program should ask the user how many subordinates they manage as well as their names. It should create a Manager object, and within the Manager object, create the subordinate Employees. The program should ask the user for the name of the subordinate employees and store their names in the subordinate Employee objects. If the user specifies the employee is not a Manager, the program should create an Employee object. All employees (including Managers), should be added to the data list of Employees. Finally, the program should print out a list of all employees. However, if an Employee is a Manager, it should also print out a list their subordinate Employees. Sample Output Employee Management System Adding Employees... Enter name: Jeff Enter id: 1 Is the employee a manager? (Y/N) n Do you want to enter more? y Enter name: Olivia Enter id: 2 Is the employee a manager? (Y/N) y How many subordinates? 2 Enter subordinate name: Jessica Enter subordinate id: 45 Enter subordinate name: Enter subordinate id: Do you want to enter more? y Enter name: Peter Enter id: 3 Is the employee a manager? (Y/N) n Do you want to enter more? n Printing Employee List 0001: Jeff 0002: Olivia olivia's Employees 0045: Jessica 9999: Unknown 0003: Peter Process finished with exit code 0 Instructions Create a new python module named [ASUrite]_main.py. Code the following within. Classes: Employee, Manager (Name all your classes and filenames appropriately). Implement an inheritance relationship between classes Employee and Manger based on the following inheritance structure: EMPLOYEE CLASS Employee Implement each of the following classes using the UML class diagram for details on the class structure and following instructions for details on the logic to be implemented. Don't forget to always put your name, class, etc. on Line 1 of ALL modules. - name: str eid: str Manager Employee + < > name : str + < > eid: str + init (name str, eid: str) str ():str + Purpose: Employee class abstracts the notion of an Employee. Use name mangling on variables. Properties: Implement properties as seen in the UML Class Diagram. Both properties must implement the property and setter decorators. All instance variables should apply name mangling in the Property decorator and the setter. name: property returns capitalized name and setter checks the name isalpha() and if true store the name in the object otherwise store 'Unknown' eid: property returns eid zero filled up to 4 spaces and setter will assign '9999' if length is zero, otherwise store the eid. Methods: str ) formats ' : ' so all employee always print both id and name. MANAGER CLASS + subordinates: list Manager + init (name: str, eid: str) + print_subordinates(): None + add_subordinate(): None Purpose: A Manager class abstracts the notion of a Manager. A Manager is also an Employee. Therefore, the Manager class should inherit from the Employee class. Fields: Maintain fields for variables which you need to access from other methods! You definitely need an list of Employees and a count. Add any more that you need! init(): Implement the initializer for Manager. Be sure to call the Employee or super initializer! NOTE: The subordinator list should not be included in the init parameter list. From the Class Diagram, the init method has name and eid as its parameters. The subordinator list should be declared inside the __init_____ method and set its value to an empty list. Methods add_subordinate() method General Method Purpose: This method should add one employee to the subordinates list. So you should ask the user details about one employee, create a new Employee and add it to the list. You will ask the user details about one employee's subordinate name and id, create a new Employee with that name and id, and add it to the list (append the newly created Employee instance to the subordinate list). print_subordinates()) method General Method Purpose: This method should loop through the subordinates list and print out a list of all employees' names and ids. main() Function Purpose: Implement a main function (or similar), which starts up your program. Call main() at the bottom of your module. Local variables: Maintain fields for variables which you need to access from other functions/methods! You definitely need a list of Employees. Add more variables that you might need! In this step, create an employee list and set it to an empty list. General Function Purpose: Maintain this function as your main program logic which runs the program. This means that this function should make sure you have an Employee list, show the welcome screen, prompt the user to enter employees as long as the user keeps saying yes, and finally displays a list of all the employees. You will use a while loop to ask if the user would like to enter more employee info. employees.append(add_employee()) You will then go through each employee in the employee list to print out each employee, then print out his/her subordinates info if there is any. To print out the subordinates info, we will need to code with the isinstance method. When user is done adding employees, print a header stating you are 'Printing Employee List'. Then proceed to print all employees. If an Employee is a Manager, it should also print out a list of all its subordinates by calling the relevant method from the Manager class. Remember - you will need to determine if the instance is a Manager first! This is similar to how we went through the list of Students in class! add_employee() Function General Function Purpose: This function should return one employee to main to be added to the list. Therefore, you should ask the user details about one employee as well as whether the employee is a manager or not. Depending on the answer, you should create either an Employee object or a Manager object. If the user specifies that the employee is a manager, it should ask the user how many subordinates are to be added. You should call the relevant method from the Manager class, however many times as needed. Make sure you return the employee (be it Manager or Employee) to main to be added to the list of employees you are maintaining in the main function! Notes: 1. We will ask the user to enter the employee's name, id, and if the employee is a manager. If the employee is a manager, then we will create a Manager instance with the entered employee name and id. 2. We will then ask 'How many subordinators?'. Based on the number the user provided, we will run a for loop to add_subordinate(). We will use the Manager instance variable to access the add_subordinate() method. If that is temp_employee, then you will code it as temp_employee.add_subordinate() 3. If the employee is not a manager, we will create an Employee instance. 4. We will then return the Manager or the Employee instance to the main method. Class Employee is implemented properly including properties Class Manager is implemented properly. Class Manager manages the list of subordinates, e.g. adding them, printing subordinate list, etc. main Function manages a list of Employees. There should be no separate list of Managers. Employees who are managers are managed using isinstance. Function is implemented for Adding Employees. Program input/out is done as expected according to sample program screenshot. Variable names are descriptive variable names conform to PEP8 standards Functions/Methods use snake_case per PEP8 Program has relevant comments documenting the code Learning Outcomes 1. Implement derived classes using inheritance 2. Utilize the protected modifier and base constructors 3. Implement polymorphism Program Overview In this program, you will create a data list of Employees. Each Employee has a name & and ID. Managers must also be part of this data list. A manager is an employee as well. However, in addition to managers having all the characteristics of employees, managers also manage employees as subordinates. Therefore, a Manager has a list of Employees they manage as well as a count of how many subordinates they have. Your application should ask the user for details to maintain the list of employees. For each employee, the program should ask the user for the name and whether or not the employee is a manager. If the user specifies that the employee is a Manager, the program should ask the user how many subordinates they manage as well as their names. It should create a Manager object, and within the Manager object, create the subordinate Employees. The program should ask the user for the name of the subordinate employees and store their names in the subordinate Employee objects. If the user specifies the employee is not a Manager, the program should create an Employee object. All employees (including Managers), should be added to the data list of Employees. Finally, the program should print out a list of all employees. However, if an Employee is a Manager, it should also print out a list their subordinate Employees. Sample Output Employee Management System Adding Employees... Enter name: Jeff Enter id: 1 Is the employee a manager? (Y/N) n Do you want to enter more? y Enter name: Olivia Enter id: 2 Is the employee a manager? (Y/N) y How many subordinates? 2 Enter subordinate name: Jessica Enter subordinate id: 45 Enter subordinate name: Enter subordinate id: Do you want to enter more? y Enter name: Peter Enter id: 3 Is the employee a manager? (Y/N) n Do you want to enter more? n Printing Employee List 0001: Jeff 0002: Olivia olivia's Employees 0045: Jessica 9999: Unknown 0003: Peter Process finished with exit code 0 Instructions Create a new python module named [ASUrite]_main.py. Code the following within. Classes: Employee, Manager (Name all your classes and filenames appropriately). Implement an inheritance relationship between classes Employee and Manger based on the following inheritance structure: EMPLOYEE CLASS Employee Implement each of the following classes using the UML class diagram for details on the class structure and following instructions for details on the logic to be implemented. Don't forget to always put your name, class, etc. on Line 1 of ALL modules. - name: str eid: str Manager Employee + < > name : str + < > eid: str + init (name str, eid: str) str ():str + Purpose: Employee class abstracts the notion of an Employee. Use name mangling on variables. Properties: Implement properties as seen in the UML Class Diagram. Both properties must implement the property and setter decorators. All instance variables should apply name mangling in the Property decorator and the setter. name: property returns capitalized name and setter checks the name isalpha() and if true store the name in the object otherwise store 'Unknown' eid: property returns eid zero filled up to 4 spaces and setter will assign '9999' if length is zero, otherwise store the eid. Methods: str ) formats ' : ' so all employee always print both id and name. MANAGER CLASS + subordinates: list Manager + init (name: str, eid: str) + print_subordinates(): None + add_subordinate(): None Purpose: A Manager class abstracts the notion of a Manager. A Manager is also an Employee. Therefore, the Manager class should inherit from the Employee class. Fields: Maintain fields for variables which you need to access from other methods! You definitely need an list of Employees and a count. Add any more that you need! init(): Implement the initializer for Manager. Be sure to call the Employee or super initializer! NOTE: The subordinator list should not be included in the init parameter list. From the Class Diagram, the init method has name and eid as its parameters. The subordinator list should be declared inside the __init_____ method and set its value to an empty list. Methods add_subordinate() method General Method Purpose: This method should add one employee to the subordinates list. So you should ask the user details about one employee, create a new Employee and add it to the list. You will ask the user details about one employee's subordinate name and id, create a new Employee with that name and id, and add it to the list (append the newly created Employee instance to the subordinate list). print_subordinates()) method General Method Purpose: This method should loop through the subordinates list and print out a list of all employees' names and ids. main() Function Purpose: Implement a main function (or similar), which starts up your program. Call main() at the bottom of your module. Local variables: Maintain fields for variables which you need to access from other functions/methods! You definitely need a list of Employees. Add more variables that you might need! In this step, create an employee list and set it to an empty list. General Function Purpose: Maintain this function as your main program logic which runs the program. This means that this function should make sure you have an Employee list, show the welcome screen, prompt the user to enter employees as long as the user keeps saying yes, and finally displays a list of all the employees. You will use a while loop to ask if the user would like to enter more employee info. employees.append(add_employee()) You will then go through each employee in the employee list to print out each employee, then print out his/her subordinates info if there is any. To print out the subordinates info, we will need to code with the isinstance method. When user is done adding employees, print a header stating you are 'Printing Employee List'. Then proceed to print all employees. If an Employee is a Manager, it should also print out a list of all its subordinates by calling the relevant method from the Manager class. Remember - you will need to determine if the instance is a Manager first! This is similar to how we went through the list of Students in class! add_employee() Function General Function Purpose: This function should return one employee to main to be added to the list. Therefore, you should ask the user details about one employee as well as whether the employee is a manager or not. Depending on the answer, you should create either an Employee object or a Manager object. If the user specifies that the employee is a manager, it should ask the user how many subordinates are to be added. You should call the relevant method from the Manager class, however many times as needed. Make sure you return the employee (be it Manager or Employee) to main to be added to the list of employees you are maintaining in the main function! Notes: 1. We will ask the user to enter the employee's name, id, and if the employee is a manager. If the employee is a manager, then we will create a Manager instance with the entered employee name and id. 2. We will then ask 'How many subordinators?'. Based on the number the user provided, we will run a for loop to add_subordinate(). We will use the Manager instance variable to access the add_subordinate() method. If that is temp_employee, then you will code it as temp_employee.add_subordinate() 3. If the employee is not a manager, we will create an Employee instance. 4. We will then return the Manager or the Employee instance to the main method. Class Employee is implemented properly including properties Class Manager is implemented properly. Class Manager manages the list of subordinates, e.g. adding them, printing subordinate list, etc. main Function manages a list of Employees. There should be no separate list of Managers. Employees who are managers are managed using isinstance. Function is implemented for Adding Employees. Program input/out is done as expected according to sample program screenshot. Variable names are descriptive variable names conform to PEP8 standards Functions/Methods use snake_case per PEP8 Program has relevant comments documenting the code
Expert Answer:
Related Book For
Practicing Statistics Guided Investigations For The Second Course
ISBN: 9780321586018
1st Edition
Authors: Shonda Kuiper, Jeff Sklar
Posted Date:
Students also viewed these programming questions
-
Image transcription text Module 5 Discussion A' Instructions: This discussion will be completed in two parts, and will give you an opportunity to reect upon this week's content and to interact with...
-
Choose a topic that can be applied to one of the following economic concepts. (Possible curves: Lorenz curve, marginal product of labor curve, labor demand and supply curves, utility function and...
-
3. How do the marginal costs of pollution reduction and the marginal costs of pollution damage change as pollution levels increase? The marginal costs of pollution reduction remain constant and the...
-
Belinda was involved in a boating accident in 2015. Her speedboat, which was used only for personal use and had a fair market value of $28,000 and an adjusted basis of $14,000, was completely...
-
The formaldehyde content of a pesticide preparation was determined by weighing 0.2985 g of the liquid sample into a flask containing 50.0 mL of 0.0959 M NaOH and 50 mL of 3% H2O2. Upon heating, the...
-
Epic Systems is a Wisconsin health care software company. In 2014, Epic introduced a company policy that required employees to use individual arbitration in any disputes. Jacob Lewis, an Epic...
-
Luxman Company has several processing departments. Costs charged to the Assembly Department for October 2012 totaled $1,298,400 as follows. Production records show that 25,000 units were in beginning...
-
Part 1: How long does it take for an investment to double in value if it earns (a) 4%, (b) 6%, (c) 9%, (d) 12%, (e) 15% annual compound interest? Solve above using method of 1) Interpolation (Using...
-
Q.3 a) Which type of molecules exhibit infra-red spectra? Calculate the vibrational energy and force constant of 'H'F if its vibrational frequency is 3.0 x 1014 Hz. b) Prove that the eigenvalues of a...
-
What is the definition of a casualty loss?
-
Baker Industriess net income is $24,000, its interest expense is $5,000, and its tax rate is 25%. Its notes payable equals $27,000, long-term debt equals $75,000, and common equity equals $250,000....
-
What restrictions apply to the dividendsreceived deduction of dividends received from debt-financed stock purchases?
-
How is book value per share calculated? Explain how inflation and R&D programs might cause book values to deviate from market values.
-
What are the benefits of installment reporting?
-
On March 1, 2019, Iron Inc., a public company, issued $800,000, 10%, 10-year bonds dated March 1, 2019, with interest payable semi-annually on March 1 and September 1. The market yield at issuance is...
-
Chapter 9 Stock Valuation at Ragan Engines Input area: Shares owned by each sibling Ragan EPS Dividend to each sibling Ragan ROE Ragan required return Blue Ribband Motors Corp. Bon Voyage Marine,...
-
Create individual value plots of the eight possible factor-level groups listed in Table 4.1. a. Do you see any patterns in the PopRate among these groups? b. Does the spread of the responses within...
-
a. Develop a general Hasse diagram for a split- plot design with the following characteristics: Whole- plot factor A has a levels (i = 1, 2, c, a). Split- plot factor B has b levels (j = 1, 2, c,...
-
For this problem, use the Normal data set. The first column of data actually is a random sample from a normal distribution. a. Use software to create a histogram and normal probability plot of the...
-
Flaherty Ltd sells two types of shoes, mens shoes and womens shoes. During the financial year ended 30 June 2019, fixed costs were $460 800 and sales were in the ratio of three units (pairs) of mens...
-
Newbery and Newstead is a public accounting firm specialising in auditing local medium-sized businesses. Fees charged for each audit are determined on the basis of identifiable hours worked on an...
-
Hotbox Ltd produces pizza boxes using two processes cutting and packaging. The production budget for the year ending 30 June 2019 estimated raw materials use of $400 000, factory overhead of $270...
Study smarter with the SolutionInn App