Hausaufgabe: Erweiterung eines objektorientierten Programms
Completion requirements
Erweitern Sie das untenstehende Programm um ein weiteres Objekt auto2, dass 200 km/h schnell fährt!
class Auto:
def __init__(self, v): # Konstruktor
self.__v = v # v ist privat und wird durch Konstruktor initialisiert
def gasGeben(self, v): # Methode
if(v>250):
self.__v = 250
else:
self.__v = v
def tacho(self):
print(self.__v)
auto1 = Auto(0)
#print(auto1.v)
# auto1.v = 100 # bei Datenkapselung nicht mehr erlaubt
auto1.gasGeben(10000)
auto1.tacho()