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