Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()