Could you tell me how to fix the error in testing the following code: class Employee: """ The employee class has a constructor and getter methods. The constructor has input arguments""" # Assigns values for id, name, salary, and email from input arguments def __init__(self, i, n, s, e): self.id = i self.name = n self.sal = s self.email = e # getter function for name def get_name(self): return self.name # getter function for ID def get_id(self): return self.id # getter function for salary def get_sal(self): return self.sal # getter function for email def get_email(self): return self.email def make_employee_dict(ids, names, sal, emails): """Function to create employee object and the dictionary using those objects""" # k is the length of all the lists k = len(ids) emp_dict = dict() # Making employee object and adding to dictionary for i in range(k): e = Employee(ids[i], names[i], sal[i], emails[i]) emp_dict[ids[i]] = e # return the dictionary return emp_dict # Testing emp_names = ["Jean", "Kat", "Pomona"] emp_ids = ["100", "101", "102"] emp_sals = [30, 35, 28] emp_emails = ["Jean@aol.com", "Kat@aol.com", "Pomona@aol.com"] result = make_employee_dict(emp_names, emp_ids, emp_sals, emp_emails) print(result["100"].get_name())

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

Could you tell me how to fix the error in testing the following code:


class Employee:
""" The employee class has a constructor and getter methods.
The constructor has input arguments"""

# Assigns values for id, name, salary, and email from input arguments
def __init__(self, i, n, s, e):
self.id = i
self.name = n
self.sal = s
self.email = e

# getter function for name
def get_name(self):
return self.name

# getter function for ID
def get_id(self):
return self.id

# getter function for salary
def get_sal(self):
return self.sal

# getter function for email
def get_email(self):
return self.email


def make_employee_dict(ids, names, sal, emails):
"""Function to create employee object and the dictionary
using those objects"""

# k is the length of all the lists
k = len(ids)
emp_dict = dict()

# Making employee object and adding to dictionary
for i in range(k):
e = Employee(ids[i], names[i], sal[i], emails[i])
emp_dict[ids[i]] = e
# return the dictionary
return emp_dict


# Testing
emp_names = ["Jean", "Kat", "Pomona"]
emp_ids = ["100", "101", "102"]
emp_sals = [30, 35, 28]
emp_emails = ["Jean@aol.com", "Kat@aol.com", "Pomona@aol.com"]
result = make_employee_dict(emp_names, emp_ids, emp_sals, emp_emails)
print(result["100"].get_name())

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage