Animal

class Animal:
 
    def __init__(self, species):
        self._species = species
 
    def move(self):
        print("Tier weiss nicht konkret, wie es sich bewegen soll")

Bird

from animal import Animal
 
class Bird(Animal):
 
    def __init__(self, species, name):
        super().__init__(species)
        self.__name = name
 
    def move(self):
        print(self._species + " mit Name " + self.__name + " fliegt")

Cow

from animal import Animal
 
class Cow(Animal):
 
    def __init__(self, species, name):
        super().__init__(species)
        self.__name = name
 
    def move(self):
        print(self._species + " mit Name " + self.__name + " läuft")

Fish

from animal import Animal
 
class Fish(Animal):
 
    def __init__(self, species, name):
        super().__init__(species)
        self.__name = name
 
    def move(self):
        print(self._species + " mit Name " + self.__name + " schwimmt")

© René Probst

  • modul/m320/learningunits/lu06/loesungen/lu07-aufgabe_5.txt
  • Last modified: 2023/11/13 08:56
  • by 127.0.0.1