Skip to main content
eick-at moodle
  • Home
  • Calendar
  • More
You are currently using guest access
Log in
eick-at moodle
Home Calendar
Expand all Collapse all
  1. LF 2: IT-Systeme
  2. Einführung in die Programmierung mit Python
  3. Hausaufgabe: Erweiterung eines objektorientierten Programms

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()      

You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle