-
Notifications
You must be signed in to change notification settings - Fork 0
/
vererbung.py
58 lines (39 loc) · 1.07 KB
/
vererbung.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Lebewesen():
def __init__(self, x = 0, y = 0):
self.__x = x
self.__y = y
@property
def x(self):
return self.__x
@property
def y(self):
return self.__y
@x.setter
def x(self, value):
self.__x = value
@y.setter
def y(self, value):
self.__y = value
def zeige_position(self):
print(f"{self.__x} {self.__y}")
class Hund(Lebewesen): # Hund IS-A Lebewesen
def __init__(self, rasse, name):
super().__init__() # Konstruktor der Elternklasse
self.__rasse = rasse
self.__name = name
class Katze(Lebewesen): # Katze IS-A Lebewesen
def __init__(self, name):
super().__init__() # Konstruktor der Elternklasse
self.__name = name
h1 = Hund('Dackel', 'Bob')
h1.zeige_position()
class HashText():
def print(self, text):
print(f'###{text}###')
class NumText():
def print(self, text):
print(f'123{text}123')
class MyText(NumText, HashText):
pass
text = MyText()
text.print('Das ist das Haus von Nikigraus')