Trying to come up with the solution in Python language, formatting did not trans
ID: 3864098 • Letter: T
Question
Trying to come up with the solution in Python language, formatting did not transfer well, but should be in evenly spaced columns across the page
PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name IDnumber department jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute For each attribute, there should be a method that returns the attribute Once you have written the class, write a main function that creates three Employee objects. Your main function should then do the following for each of the three objects: a. Display a message asking user to enter employee name, ID, department, and title b. Read employee name into a variable c. Call the set name method of the first object passing the name d. Read employee ID into a variable e. Call the set IDnumber method of the first object passing ID f. Read employee department into a variable g. Call the set department method of the first object passing the department h. Read employee title into a variable i. Call the set job title method of the first object passing the title After reading and storing the employee information, the main function should call a function called displayEmployees passing the three objects as arguments. The displayEmployees function should call the methods of the objects that return attributes and display the returned values. The output should be formatted as follows:
CHRISTY’S SHOP EMPLOYEE REPORT
EMPLOYEE NAME IDENTIFIER DEPARTMENT TITLE
Lily Thomas 412 Administration Manager
John Doe 132 Accounting Accountant
LaQuanda Shaka 321 Sales Associate
Explanation / Answer
""" The program is written on Python3 """ class Employee: 'Employee object with name, id, department and job title' # def __init__(self, name, id, department, job_title): # self.name = name # self.id = id # self.department = department # self.job_title = job_title # Mutators def set_name(self, name): self.name = name def set_id(self, id): self.id = id def set_department(self, department): self.department = department def set_job_title(self, job_title): self.job_title = job_title # Accessor Methods def get_name(self): return self.name def get_id(self): return self.id def get_department(self): return self.department def get_job_title(self): return self.job_title def display_employees(*args): """ It takes the employees as argument and prints the details of the employees """ print(" CHRISTY’S SHOP EMPLOYEE REPORT ") print(*["EMPLOYEE NAME", "IDENTIFIER", "DEPARTMENT", "TITLE"], sep=' ') for emp in args: print(*[emp.get_name(), emp.get_id(), emp.get_department(), emp.get_job_title()], sep=' ') def main(): e1 = Employee() e2 = Employee() e3 = Employee() emp_list = [e1, e2, e3] for emp in emp_list: name = input("Enter employee name: ") id = int(input("Enter employee id: ")) department = input("Enter employee department: ") job_title = input("Enter employee job title: ") emp.set_name(name) emp.set_id(id) emp.set_department(department) emp.set_job_title(job_title) display_employees(e1, e2, e3) if __name__ == '__main__': main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.