From 565b49b120a2acdfe78db237559d88cf5cdcc3f2 Mon Sep 17 00:00:00 2001 From: Mike Gerlach <mike.gerlach@stud.h-da.de> Date: Thu, 10 Nov 2022 01:07:11 +0000 Subject: [PATCH] Upload New File --- lab02/prohibition.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lab02/prohibition.py diff --git a/lab02/prohibition.py b/lab02/prohibition.py new file mode 100644 index 0000000..e49aae5 --- /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() + + + + + -- GitLab