diff --git a/lab02/prohibition.py b/lab02/prohibition.py new file mode 100644 index 0000000000000000000000000000000000000000..e49aae587bf042c9b6547a2033ab5eda03b1d2ea --- /dev/null +++ b/lab02/prohibition.py @@ -0,0 +1,38 @@ +# Programmieren 2 Praktikum 2/3 Gerlach, Mike (768100) + +class Whisky(object): + + def __init__(self, alc): + self.alc = alc + + def alc(self, x): + self.alc += x + + def minAlc(self, value): + if self.alc != None: + print("Wert darf nicht mehr geƤndert werden!") + elif value >= 40: + self.alc = value + else: + print("Alkoholgehalt: {} Vol.-% zu gering!".format(value)) + + def str(self): + print("Alkoholgehalt : {} Vol.-%".format(self.alc)) + +def main(): + try: + glenmorangie18 = Whisky(alc=42) + glenmorangie18.minAlc(40) + glenmorangie18.str() + Whisky.alc(glenmorangie18, 1) + glenmorangie18.str() + except [ValueError] as vr: + print("Alkoholgehalt: {} Vol.-% zu gering!".format(*vr.args)) + +if __name__ == '__main__': + main() + + + + +