Error handling hinzugefügt
This commit is contained in:
parent
5b2b84dbf0
commit
e81f83c294
|
@ -5,7 +5,6 @@ import math
|
||||||
|
|
||||||
class Circle:
|
class Circle:
|
||||||
def __init__(self, name: str, filepath: str, length=1000, height=1000, radius=10, distance=60, offset=50):
|
def __init__(self, name: str, filepath: str, length=1000, height=1000, radius=10, distance=60, offset=50):
|
||||||
# run validations
|
|
||||||
assert length >= 0, "length can not be negative"
|
assert length >= 0, "length can not be negative"
|
||||||
assert height >= 0, "height can not be negative"
|
assert height >= 0, "height can not be negative"
|
||||||
assert radius >= 0, "radius can not be negative"
|
assert radius >= 0, "radius can not be negative"
|
||||||
|
@ -13,7 +12,6 @@ class Circle:
|
||||||
assert offset >= 0, "offset can only be 0 - 100 %"
|
assert offset >= 0, "offset can only be 0 - 100 %"
|
||||||
assert offset <= 100, "offset can only be 0 - 100 %"
|
assert offset <= 100, "offset can only be 0 - 100 %"
|
||||||
|
|
||||||
# Assign to self object
|
|
||||||
self.__length = length
|
self.__length = length
|
||||||
self.__height = height
|
self.__height = height
|
||||||
self.__radius = radius
|
self.__radius = radius
|
||||||
|
@ -108,26 +106,31 @@ if __name__ == '__main__':
|
||||||
print(f"\nStandardwerte\nHöhe: {circle.height} px\nLänge: {circle.length} px\nRadius: {circle.radius} px\nAbstand: {circle.distance} px\nOffset: {circle.offset_percentage} %\n")
|
print(f"\nStandardwerte\nHöhe: {circle.height} px\nLänge: {circle.length} px\nRadius: {circle.radius} px\nAbstand: {circle.distance} px\nOffset: {circle.offset_percentage} %\n")
|
||||||
selection_flag = True
|
selection_flag = True
|
||||||
while selection_flag:
|
while selection_flag:
|
||||||
parameter_selection = int(input("Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Radius, 4: Abstand, 5: Offste):"))
|
try:
|
||||||
if parameter_selection == 0:
|
parameter_selection = int(input("Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Radius, 4: Abstand, 5: Offste):"))
|
||||||
selection_flag = False
|
if parameter_selection == 0:
|
||||||
elif parameter_selection == 1:
|
selection_flag = False
|
||||||
height = int(input("Höhe in Pixeln eingeben:"))
|
elif parameter_selection == 1:
|
||||||
circle.height = height
|
height = int(input("Höhe in Pixeln eingeben:"))
|
||||||
elif parameter_selection == 2:
|
circle.height = height
|
||||||
length = int(input("Länge in Pixeln:"))
|
elif parameter_selection == 2:
|
||||||
circle.length = length
|
length = int(input("Länge in Pixeln:"))
|
||||||
elif parameter_selection == 3:
|
circle.length = length
|
||||||
radius = int(input("Radius in Pixeln:"))
|
elif parameter_selection == 3:
|
||||||
circle.radius = radius
|
radius = int(input("Radius in Pixeln:"))
|
||||||
elif parameter_selection == 4:
|
circle.radius = radius
|
||||||
distance = int(input("Abstand in Pixeln:"))
|
elif parameter_selection == 4:
|
||||||
circle.distance = distance
|
distance = int(input("Abstand in Pixeln:"))
|
||||||
elif parameter_selection == 5:
|
circle.distance = distance
|
||||||
offset = int(input("Offset in %:"))
|
elif parameter_selection == 5:
|
||||||
circle.offset = offset
|
offset = int(input("Offset in %:"))
|
||||||
else:
|
circle.offset = offset
|
||||||
|
else:
|
||||||
|
print("ungültiger Wert")
|
||||||
|
except ValueError:
|
||||||
print("ungültiger Wert")
|
print("ungültiger Wert")
|
||||||
|
except AssertionError as error:
|
||||||
|
print(error)
|
||||||
|
|
||||||
circle.circle_generation()
|
circle.circle_generation()
|
||||||
elif shape == 2:
|
elif shape == 2:
|
||||||
|
|
Loading…
Reference in New Issue