Alle Dateien aus dem Pythonkurs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
855 B

class Fahrzeug:
def __init__(self, marke, modell, farbe):
self.marke = marke
self.modell = modell
self.farbe = farbe
def __str__(self):
return f'{self.marke} {self.modell} {self.farbe})'
#Klasse Auto erbt von Fahrzeug
class Auto(Fahrzeug):
def __init__(self, marke, modell, farbe, ps):
super().__init__(marke, modell, farbe)
self.ps = ps
def __str__(self):
return f'{super().__str__()} mit {self.ps} PS'
#Klasse Fahhrad erbt von Fahrzeug
class Fahrrad(Fahrzeug):
def __init__(self, marke, modell, farbe):
super().__init__(marke, modell, farbe)
def __str__(self):
return super().__str__()
bond = Auto('Aston Martin','DB5','grau','286')
mcfly = Auto('Delorean', 'DMC-12','grau','132')
eliot = Fahrrad('Kuwahara','ET-1','weiß')
print(str(bond))
print(str(mcfly))
print(str(eliot))