feat: robotpy is a tutorial for polymorphism

This commit is contained in:
Sandro Zimmermann 2026-03-05 11:17:10 +01:00
parent 81dc543bf5
commit 16497f059c

View File

@ -0,0 +1,21 @@
class Dog:
def speak(self) -> str:
return "wuff"
class Cat:
def speak(self) -> str:
return "miau"
class Robot:
def speak(self) -> str:
return "bip bup"
def chorus(animals) -> list:
for a in animals:
print(a.speak())
chorus([Dog(), Cat(), Robot()])