Skip to content
Snippets Groups Projects
Commit 4b096142 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Fixed bugs in the classify method.

parent e2494fda
Branches main
No related tags found
No related merge requests found
...@@ -19,22 +19,22 @@ class TriangleApp(App): ...@@ -19,22 +19,22 @@ class TriangleApp(App):
classification = StringProperty() classification = StringProperty()
@staticmethod @staticmethod
def classify(a, b, c): # buggy def classify(a, b, c):
if a * b * c < 0: if a < 0 or b < 0 or c < 0:
return Classification.INVALID return Classification.INVALID
if a == b and b == c: semiperimeter = (a + b + c) / 2
return Classification.EQUILATERAL
if a == b or b == c:
return Classification.ISOSCELES
maximum = a maximum = a
if b > maximum: if b > maximum:
maximum = b maximum = b
if c > maximum: if c > maximum:
maximum = c maximum = c
semiperimeter = a + b + c / 2
if maximum > semiperimeter: if maximum > semiperimeter:
return Classification.INVALID return Classification.INVALID
if a ** 2 + b ** 2 == c ** 2 or b ** 2 + a ** 2 == c ** 2 or c ** 2 + b ** 2 == a ** 2: if a == b and b == c:
return Classification.EQUILATERAL
if a == b or b == c or c == a:
return Classification.ISOSCELES
if a ** 2 + b ** 2 == c ** 2 or b ** 2 + c ** 2 == a ** 2 or c ** 2 + a ** 2 == b ** 2:
return Classification.RIGHT return Classification.RIGHT
return Classification.SCALENE return Classification.SCALENE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment