Ask Question
27 August, 10:29

Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title.

Once you have written the class, write a python program that creates 3 Employee objects to hold the following dа ta:

Name: Susan Meyers, ID number: 47899, Department: Accounting, Job Title: Vice President

Name: Mark Jones, ID Number: 39119, Department: IT, Job Title: Programmer

Name: Jon Rogers, ID Number: 81774, Department: Manufacturing, Job Title: Engineer

The prgram should store this data in the 3 objects and then display the data for each employee on the screen.

+3
Answers (1)
  1. 27 August, 10:48
    0
    firstly we have to create class and then constructors and method

    let start with class

    class Employee:

    def __init__ (self, name, id, department, title):

    self.__name = name

    self.__id = id

    self.__department = department

    self.__title = title

    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_title (self, title):

    self.__title = title

    def get_name (self):

    return self.__name

    def get_id (self):

    return self.__id

    def get_department (self):

    return self.__department

    def get_title (self):

    return self.__title

    def __str__ (self):

    return 'Name: ' + self.__name + /

    '/nID number: ' + self.__id + /

    '/nDepartment: ' + self.__department + /

    '/nTitle: ' + self.__title

    Now to test the program

    import emp

    def main ():

    emp1 = emp. Employee ('name', 'id', 'department', 'title')

    emp2 = emp. Employee ('name', 'id', 'department', 'title')

    emp3 = emp. Employee ('name', 'id', 'department', 'title')

    emp1. set_name ('Susan Meyers')

    emp1. set_id ('47899')

    emp1. set_department ('Accounting')

    emp1. set_title ('Vice President')

    emp2. set_name ('Mark Jones')

    emp2. set_id ('39119')

    emp2. set_department ('IT')

    emp2. set_title ('Programmer')

    emp3. set_name ('Joy Rogersr')

    emp3. set_id ('81774')

    emp3. set_department ('Manufacturing')

    emp3. set_title ('Engineer')

    print ()

    print (emp1)

    print ()

    print (emp2)

    print ()

    print (emp3)

    main ()
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers