-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacme.py
More file actions
52 lines (44 loc) · 1.58 KB
/
acme.py
File metadata and controls
52 lines (44 loc) · 1.58 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import random
from random import randint
class Product:
""" Writing python class for Acme (Part 1 - Keeping it Classy)"""
def __init__(self, name=None, price=10, weight=20, flammability=0.5):
self.name = name
self.price = price
self.weight = weight
self.flammability = flammability
self.identifier = randint(1000000, 9999999)
# Adding methods
def stealability(self):
"""Calculates how whether a Product will be stolen
based on price and weight."""
ratio = self.price/self.weight
if ratio < 0.5:
return print("Not so stealable...")
elif 1 > ratio >= 0.5:
return print("Kinda stealable.")
else:
print("Very stealable!")
def explode(self):
"""Calculates a Product's liklihood to combust based on
flammability and weight."""
product = self.flammability * self.weight
if product < 10:
return print("fizzle")
elif 50 > product >= 10:
return print("boom!")
else:
print("BABOOM!!")
class BoxingGlove(Product):
"""Defines a Boxing Gloves as a subset of Products for Acme."""
def __init__(self, name, price =10, weight=10, flammability=0.5):
super().__init__(self, name, price, weight, flammability)
def explode (self):
return print("It's a glove.")
def punch (self):
if self.weight < 5:
return print("That tickles.")
elif 15 > product >= 5:
return print("Hey, that hurt!")
else:
print("OUCH!!")