Kuhlercode
class Person:
def __init__(self, firstname, lastname, age, gender):
self.firstname = firstname
self.lastname = lastname
self.age = age
self.gender = gender
def get_infos(self):
return f"{self.firstname} {self.lastname.upper()} ({self.age} Jahre alt)"
class Teacher(Person):
def __init__(self, firstname, lastname, age, gender, course):
super().__init__(firstname, lastname, age, gender)
self.course = course
def get_infos(self):
person_role = "Lehrer"
if self.gender.lower() == "w":
person_role = "Lehrerin"
return f"{super().get_infos()} - {person_role} ({self.course})"
class Student(Person):
def init(self, firstname, lastname, age, gender, school_year):
super().init(firstname,lastname,age,gender)
self.school_year = school_year
def get_infos(self):
person_role = "Schüler"
if self.gender.lower() == "w":
person_role = "Schülerin"
return f"{super().get_infos()} - {person_role} im {self.school_year}. Jahr am KAE"
print()
student01 = Student( "Tom", "Simon", 15, "M", 4)
student02 = Student("Nada", "Fahed", 17, "W", 6)
teacher01 = Teacher("Cédric", "Krings", 47, "M", "Informatik")
teacher02 = Teacher("Rachel", "Küpper", 36, "w", "Englisch")
print(student01.get_infos())
print(student02.get_infos())
print(teacher01.get_infos())
print(teacher02.get_infos())
print()