Skip to main content

Managing Employee details

Project description

This is a very simple Employee data manager

class Employee:

    num_of_emps = 0
    raise_amt = 1.04

    def __init__(self, first, last, pay):
        self.first = first
        self.last = last
        self.email = first + '.' + last + '@DataSocle.ai'
        self.pay = pay

        Employee.num_of_emps += 1

    def fullname(self):
        return '{} {}'.format(self.first, self.last)

    def apply_raise(self):
        self.pay = int(self.pay * self.raise_amt)

    def details(self):
        return '{} {} {} {}'.format(self.first, self.last, self.email, self.pay)

    def __str__(self):
        return '{} {} - {} - {}'.format(self.first, self.last, self.email,  self.pay)

    @classmethod
    def set_raise_amt(cls, amount):
        cls.raise_amt = amount

    @classmethod
    def from_string(cls, emp_str):
        first, last, pay = emp_str.split('-')
        return cls(first, last, pay)
'''
class Company(Employee):
    def __init__(self, first, last, pay, company):
        super().__init__(first, last, pay)
        self.company = company
        pass
'''
class Manager(Employee):

    def __init__(self, first, last, pay, employees = None):    #Creating List of employees
        super().__init__(first, last, pay)
        if employees is None:
            self.employees = []
        else:
            self.employees = employees

    def add_emp(self, emp):
        if emp in self.employees:
            self.employees.append(emp)

    def remove_emp(self, emp):
        if emp in self.employees:
            self.employees.remove(emp)

    def print_emps(self):
        print("Here the list of Employees under Manager - {} {}".format(self.first, self.last))
        for emp in self.employees:
            print('-->',emp.fullname())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Employee-0.0.4-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page