Employee Class Hierarchy

Write a class Employee and then create child classes Manager, Engineer, Intern, each with a unique method responsibilities that returns the key responsibilities of the respective employee roles.

Example 1:

Input: Manager 
Output: "Manager: Plan, coordinate and manage staff and organizational activities."

Example 2:

Input: Engineer 
Output: "Engineer: Apply principles of science and mathematics to develop economical solutions to technical problems."

Implement a method responsibilities in each of the child classes that returns the respective responsibilities of the employee roles.

class Employee:
    def responsibilities(self):
        pass

class Manager(Employee):
    def responsibilities(self):
        return "Manager: Plan, coordinate and manage staff and organizational activities."

class Engineer(Employee):
    def responsibilities(self):
        return "Engineer: Apply principles of science and mathematics to develop economical solutions to technical problems."

class Intern(Employee):
    def responsibilities(self):
        return "Intern: Learning and gaining experience in their desired field."

# Test the classes
manager = Manager()
print(manager.responsibilities())

engineer = Engineer()
print(engineer.responsibilities())

intern = Intern()
print(intern.responsibilities())

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!