"test/phpunit/ModulesTest.php" did not exist on "6e0b42afb1da11640bd72013128ad089b3a0ff43"
Select Git revision
divide-and-conquer-in-class.code-workspace
Forked from
SOFT Core / SOFT 260 / Divide and Conquer in Class
Source project has a limited visibility.
-
Brady James Garvin authored
Update VSCode `files.eol` setting to modern format and include ESLint configuration name to avoid package-lock.json from being marked as changed.
Brady James Garvin authoredUpdate VSCode `files.eol` setting to modern format and include ESLint configuration name to avoid package-lock.json from being marked as changed.
main.py 1.56 KiB
from enum import Enum
from kivy.app import App
from kivy.properties import StringProperty
class Classification(Enum):
INVALID = 'Invalid'
EQUILATERAL = 'Equilateral'
ISOSCELES = 'Isosceles'
RIGHT = 'Right'
SCALENE = 'Scalene'
class TriangleApp(App):
a = StringProperty('')
b = StringProperty('')
c = StringProperty('')
classification = StringProperty()
@staticmethod
def classify(a, b, c): # buggy
if a * b * c < 0:
return Classification.INVALID
if a == b and b == c:
return Classification.EQUILATERAL
if a == b or b == c:
return Classification.ISOSCELES
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:
return Classification.RIGHT
return Classification.SCALENE
def update(self):
try:
self.classification = TriangleApp.classify(int(self.a), int(self.b), int(self.c)).value
except ValueError:
self.classification = f'{Classification.INVALID.value} (non-integer sides)'
def on_start(self):
self.update()
def on_a(self, _, __):
self.update()
def on_b(self, _, __):
self.update()
def on_c(self, _, __):
self.update()
if __name__ == '__main__':
app = TriangleApp()
app.run()