python-kurs-softed/beispiele/employeeclass2.py

36 lines
770 B
Python
Raw Permalink Normal View History

# employeeclass1.py
from personclass2 import Person
class Employee(Person):
def __init__(self, name="", age=0, gender=None, employee_id=None, salary=0):
super().__init__(name=name, age=age, gender=gender)
self.employee_id = employee_id
self.salary = salary
def __str__(self):
return f"Employee: name={self.name} employee_id={self.employee_id}"
employee1 = Employee()
print(employee1)
print(employee1.__class__)
print(employee1.name)
print(employee1.age)
print(employee1.gender)
employee2 = Employee("Joe Doe", 32, gender="m", employee_id=1, salary=2000)
print(employee2)
print(employee2.__class__)
print(employee2.name)
print(employee2.age)
print(employee2.gender)
print(employee2.employee_id)
print(employee2.salary)