-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClasses and Objects
More file actions
35 lines (32 loc) · 1.01 KB
/
Classes and Objects
File metadata and controls
35 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""You can use this class to represent how classy someone
or something is.
"Classy" is interchangable with "fancy".
If you add fancy-looking items, you will increase
your "classiness".
Create a function in "Classy" that takes a string as
input and adds it to the "items" list.
Another method should calculate the "classiness"
value based on the items.
The following items have classiness points associated
with them:
"tophat" = 2
"bowtie" = 4
"monocle" = 5
Everything else has 0 points.
Use the test cases below to guide you!"""
class Classy(object):
def __init__(self):
self.items = []
def addItem(self, item):
self.items.append(item)
def getClassiness(self):
classiness = 0
if len(self.items) > 0:
for item in self.items:
if item == "tophat":
classiness += 2
elif item == "bowtie":
classiness += 4
elif item == "monocle":
classiness += 5
return classiness