Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Buggy Triangle Classifier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOFT Core
SOFT 161 and 162
Buggy Triangle Classifier
Commits
34339231
Commit
34339231
authored
4 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit.
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+5
-0
5 additions, 0 deletions
.gitignore
main.py
+51
-0
51 additions, 0 deletions
main.py
triangle.kv
+68
-0
68 additions, 0 deletions
triangle.kv
with
124 additions
and
0 deletions
.gitignore
0 → 100644
+
5
−
0
View file @
34339231
*~
*.pyc
*.pyo
.idea
This diff is collapsed.
Click to expand it.
main.py
0 → 100644
+
51
−
0
View file @
34339231
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
):
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
):
ids
=
self
.
root
.
ids
try
:
self
.
classification
=
TriangleApp
.
classify
(
int
(
ids
.
a
.
text
),
int
(
ids
.
b
.
text
),
int
(
ids
.
c
.
text
)).
value
except
ValueError
:
self
.
classification
=
f
'
{
Classification
.
INVALID
.
value
}
(non-integer sides)
'
def
on_start
(
self
):
self
.
update
()
if
__name__
==
'
__main__
'
:
app
=
TriangleApp
()
app
.
run
()
This diff is collapsed.
Click to expand it.
triangle.kv
0 → 100644
+
68
−
0
View file @
34339231
BoxLayout:
orientation: 'vertical'
Widget:
size_hint: (1.0, 2.0)
BoxLayout:
orientation: 'horizontal'
size_hint: (1.0, 0.0)
height: sp(40)
Widget:
Label:
text: 'Side A:'
font_size: sp(36)
Widget:
size_hint: (0.25, 1.0)
TextInput:
id: a
multiline: False
write_tab: False
text: ''
font_size: sp(24)
on_text: app.update()
Widget:
BoxLayout:
orientation: 'horizontal'
size_hint: (1.0, 0.0)
height: sp(40)
Widget:
Label:
text: 'Side B:'
font_size: sp(36)
Widget:
size_hint: (0.25, 1.0)
TextInput:
id: b
multiline: False
write_tab: False
text: ''
font_size: sp(24)
on_text: app.update()
Widget:
BoxLayout:
orientation: 'horizontal'
size_hint: (1.0, 0.0)
height: sp(40)
Widget:
Label:
text: 'Side C:'
font_size: sp(36)
Widget:
size_hint: (0.25, 1.0)
TextInput:
id: c
multiline: False
write_tab: False
text: ''
font_size: sp(24)
on_text: app.update()
Widget:
Widget:
BoxLayout:
orientation: 'horizontal'
Label:
text: app.classification
font_size: sp(36)
text_size: self.size
halign: 'center'
Widget:
size_hint: (0.0, 1.5)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment