예제 #1
0
 def __init__(self, id, name, hours_worked, hour_rate):
     HourlyPolicy.__init__(self, hours_worked, hour_rate)
     super().__init__(id, name)
예제 #2
0
from hr import PayrollSystem, HourlyPolicy
from productivity import ProductivitySystem
from employees import EmployeeDatabase

productivity_system = ProductivitySystem()
payroll_system = PayrollSystem()
employee_database = EmployeeDatabase()

employees = employee_database.employees()

manager = employees[0]
manager.payroll = HourlyPolicy(55)

productivity_system.track(employees, 40)
payroll_system.calculate_payroll(employees)
예제 #3
0
from hr import PayrollSystem
from hr import HourlyPolicy
from productivity import ProductivitySystem
from employees import EmployeeDatabase

productivity_system = ProductivitySystem()
payroll_system = PayrollSystem()
employee_database = EmployeeDatabase()

print('-'*100)
print('initiating a database of employees')
employees = employee_database.employees  # @property

# if we wanted to change one of the employees - and no need to mess with inheritance!
manager = employees[0]
manager.policy = HourlyPolicy(55)

print('-'*100)
print('initiating hour countring')
productivity_system.track(employees, 40)
print('-'*100)
print('initiating payroll')
payroll_system.calculate_payroll(employees)

"""
OUTPUT:

Tracking Employee Productivity
==============================
Employee 1 - Mary Poppins:
- screams and yells for 40 hours.