Question

In: Computer Science

Submission Question 3: Polymorphism Problem You are writing software for a company’s human resources department. As...

Submission Question 3: Polymorphism

Problem

You are writing software for a company’s human resources department. As part of the requirements, it would like to have a function that calculates the salary of an individual based on the position he or she holds, years of service, and hours worked.

This program will demonstrate the following:

  • How to create an abstract class,
  • How to overload a method,
  • How to use polymorphism to call functions on similar objects.

Solving the Problem

Step 1

The first thing that you must determine is what attributes are common to all employees and what methods they can share. Can salary be easily calculated by the same method without some additional input from the user? By using polymorphism, you can make one method that calculates salaries for different groups. First, determine the base class and what method needs to be implemented by the child classes. By making the calcSalary() method abstract, it will be a required method of the child classes.

Step 2

You can then define the child classes that inherit the shared attributes from the base Employee class but also inherit the requirement that they implement from the calcSalary() method. Each employee type will have a different set of attributes and a different method of calculating the salary, but the same method call will be used to calculate it.

Step 3

You can now create a list to hold all employee types and populate it.

Step 4

Because you used polymorphism in the classes, you can now use one loop to calculate and output the salaries of the employees.

Documentation Guidelines:

Use Python Programming. Use good programming style (e.g., indentation for readability) and document each of your program parts with the following items (the items shown between the '<' and '>' angle brackets are only placeholders. You should replace the placeholders and the comments between them with your specific information). Your cover sheet should have some of the same information, but what follows should be at the top of each program's sheet of source code. Some lines of code should have an explanation of what is to be accomplished, this will allow someone supporting your code years later to comprehend your purpose. Be brief and to the point. Start your design by writing comment lines of pseudocode. Once that is complete, begin adding executable lines. Finally run and test your program.

Deliverable(s):

Your deliverable should be a Word document with screenshots showing the source code and running results, and discuss the issues that you had for this project related to AWS and/or Python IDE and how you solved them for all of the programs listed above as well as the inputs and outputs from running them. Submit a cover sheet with the hardcopy of your work.

Solutions

Expert Solution

Note: While copy pasting you may lose some indentation so please check that befire executing otherwise you will get indentation error.

You can copy paste in one file or create different module for each class here i have created all the class in one file.

from abc import ABC, abstractmethod
#Base class with abstract method
class Employees(ABC):
def __init__(self ,empId,name,hoursWorked):
self.empId=empId
self.name=name
self.hoursWorked =hoursWorked
@abstractmethod
def calcSalary(self):
pass
#Child classes inheriting from base class
class Manager(Employees):
def calcSalary(self):
salary = 10000+ (500* self.hoursWorked)
print('Name: '+self.name+' '+'Salary: '+ str(salary)+' EmployeeType: Manager')
class Analyst(Employees):
def calcSalary(self):
salary = 10000+ (300* self.hoursWorked)
print('Name: '+self.name+' Salary: '+ str(salary)+' EmployeeType: Analyst')
class HrExecutive(Employees):
def calcSalary(self):
salary = 10000+ (200* self.hoursWorked)
print('Name: '+self.name+' '+'Salary: '+ str(salary)+' EmployeeType: HrExecutive')
  
  
list =['manager','analyst','hrExecutive']
for employee in list:
if employee.upper() =='MANAGER':
m = Manager(2,'CapAmerica',4)
m.calcSalary()
if employee.upper() =='ANALYST':
a=Analyst(4,'Hulk',5)
a.calcSalary()
if employee.upper() =='HREXECUTIVE':
h=HrExecutive(5,'Thor',6)
h.calcSalary()
  
  


Related Solutions

Question 3. You are working in the human resource department at a large organization and your...
Question 3. You are working in the human resource department at a large organization and your department has been asking for help to build an information system to allow new job applicants to apply online. You also want to be able to keep a record of these job applicants specific skills to better help you match them to new job openings. Your department has several very skilled knowledge workers who have studied Busi 237 and you decide to build your...
C++ question. Need all cpp and header files. Part 1 - Polymorphism problem 3-1 You are...
C++ question. Need all cpp and header files. Part 1 - Polymorphism problem 3-1 You are going to build a C++ program which runs a single game of Rock, Paper, Scissors. Two players (a human player and a computer player) will compete and individually choose Rock, Paper, or Scissors. They will then simultaneously declare their choices and the winner is determined by comparing the players’ choices. Rock beats Scissors. Scissors beats Paper. Paper beats Rock. The learning objectives of this...
How the Human Resources Department rewards the employees?
How the Human Resources Department rewards the employees?
Question A1 Paula Chan, the Director of Montreal Construction Company, requests the Human Resources Department to...
Question A1 Paula Chan, the Director of Montreal Construction Company, requests the Human Resources Department to find two Senior Engineering Managers through internal recruitment. To achieve this recruiting goal, the Human Resources Manager announces the job opening internally through newsletters, bulletin boards, and intranet. In addition, the human resources manager, Mary, also uses the Human Resources Information Systems (HRIS) to identify potential candidates and contacts them to apply for promotion. Montreal Construction Company in the past five years has invested...
You have been recently hired in the human resources department at the company you have always...
You have been recently hired in the human resources department at the company you have always dreamed of working for. At the end of your first day, your manager, I. M. DeBoss, on her way out of the office says to you: “So Mr./Ms. Jones, what things come to mind when you think of the word “ethics”? Before you can answer, she asks you if you believe ethics are important for a company and if so why do you feel...
You work the human resources in your county’s criminal justice department. You have noticed that it...
You work the human resources in your county’s criminal justice department. You have noticed that it seems that probation officers miss more days of work in a year than parole officers. You think they do but you want to be sure that the difference is significant. You collect data on the number of missed days of work and determine that the mean number of missed days for parole officers is 7 and the mean number of missed days for probation...
You have been recently hired in the human resources department at the company you have always...
You have been recently hired in the human resources department at the company you have always dreamed of working for. At the end of your first day, your manager, I.M. DeBoss, on her way out of the office says to you: “So Mr./Ms. Jones, what things come to mind when you think of the word 'ethics'?" Before you can answer, she asks you if you believe ethics are important for a company and if so why do you feel that...
In this question, you are developing the human resources system in Mazoon Dairy Company and you...
In this question, you are developing the human resources system in Mazoon Dairy Company and you are the project manager. : ١. Job requirements (What are the functions that your system will do? And how will the customer assist in commercial operations)? 2.Resource requirements (resources that you will need for the project - manpower and hardware (hardware, software, and any other hardware). If you are proposing an ERP or any good specific program to give the name and some details)...
Suppose you work in a human resources department and want to see if average job satisfaction...
Suppose you work in a human resources department and want to see if average job satisfaction differs by Industry (Factor A), Level of Work Experience (Factor B), or an interaction of both Industry and Level of Work Experience (AB). You randomly select 3 workers from each of the 9 combinations of industry and work experience and administer a satisfaction survey. Using the results of the ANOVA below, if you want to test for significant interaction effects on job satisfaction, what...
The Legal Department (LE) and Human Resources Department (HR) of the XXX Corporation support the operations...
The Legal Department (LE) and Human Resources Department (HR) of the XXX Corporation support the operations of Divisions A and B of the XXX Corporation. The total cost incurred by the Legal Department in supporting A and B is $2,000,000. The total cost incurred by the Human Resources Department in supporting A and B is $10,000,000. The Legal Department devotes 400 Person-Hours (PH) to support Division A, 600 PH to support division B, and 100 PH to support the Human...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT