UNI_Python/_crashkurs/object.py
2024-02-29 22:31:32 +01:00

40 lines
659 B
Python

class Tier:
age = 0
def __init__(self, age):
self.age = age
class Katzenartig(Tier):
def schnurren(self):
print("Brrrr Brrrr Brrrr")
class Hauskatze(Katzenartig, Tier):
def __init__(self, age, name):
self.name = name
Tier.__init__(self, age)
def miau(self):
print("Miau Miau Miau")
class Grosskatze(Katzenartig, Tier):
def __init__(self, age):
Tier.__init__(self, age)
def roar(self):
print("Roar Roar Roar")
prinz = Hauskatze(11, "Prinz")
tiger = Grosskatze(5)
print(prinz.__class__.__mro__)
print(tiger.__class__.__mro__)
prinz.schnurren()
tiger.schnurren()