Skip to content
Snippets Groups Projects
prohibition.py 852 B
Newer Older
  • Learn to ignore specific revisions
  • Mike Gerlach's avatar
    Mike Gerlach committed
    # 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()