python-CSD-kursu/python-temel/employee.maas.py

39 lines
925 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class Employee:
def __init__(self, name):
self.name = name
class Worker(Employee):
def __init__(self, name, weekHours):
super().__init__(name)
self.weekHours = weekHours
def calc_salary(self):
return self.weekHours * 30
class Manager(Employee):
def __init__(self, name, prim):
super().__init__(name)
self.prim = prim
def calc_salary(self):
return 7000 + 7000 * self.prim
class SalesPerson(Employee):
def __init__(self, name, prim):
super().__init__(name)
self.prim = prim
def calc_salary(self):
return 3000 + 3000 * self.prim
employees = [Worker('Ali', 40), Manager('Veli', 0.20), SalesPerson('Selami', 0.10)]
for emp in employees:
print('Adı: {}, Maaş: {}'.format(emp.name, emp.calc_salary()))
salary = 0
for emp in employees:
salary += emp.calc_salary()
print('Toplam Maaş: {}'.format(salary))