-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (57 loc) · 1.7 KB
/
main.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import time
from pantry import Egg, Bread, Coffee
from fridge import Juice, Ham
from devices import Toaster, Fryer, EggCooker
def pour_coffee():
print('Pouring coffee..')
return Coffee()
def pour_orange_juice():
print('Pouring orangje juice')
return Juice()
def apply_jam(toast:Bread):
print('Putting jam on the toast')
def apply_butter(toast:Bread):
print('Putting butter on the toast')
def toast_bread(slices:int):
with Toaster() as toaster:
for slice in range(0, slices):
toaster.do('Putting a slice of bread in the toaster')
toaster.do('Start toasting...')
toaster.cook(seconds=4)
Toast = Bread
toaster.do('Remove toast from toaster')
return Toast()
def fry_ham(slices:int):
with Fryer() as fryer:
fryer.do(f'putting {slices} slices of ham in the pan')
fryer.do('cooking first side of ham...')
fryer.cook(seconds=3)
for slice in range(0, slices):
fryer.do('flipping a slice of ham')
fryer.do('cooking other side of ham...')
fryer.cook(seconds=3)
fryer.do('put ham on plate')
return Ham()
def cook_eggs(how_many:int) -> Egg:
with EggCooker() as egg_cooker:
egg_cooker.do('Warming the egg cooker')
egg_cooker.cook(3)
egg_cooker.do(f'cook {how_many} eggs')
egg_cooker.cook(3)
egg_cooker.do('put eggs on plate')
return Egg()
if __name__ == '__main__':
now = time.time()
eggs:Egg = cook_eggs(how_many=2)
print('eggs are ready')
ham:Ham = fry_ham(slices=3)
print('Ham is ready')
toast:Bread = toast_bread(slices=2)
apply_butter(toast)
apply_jam(toast)
print('Toast is ready')
cup:Coffee = pour_coffee()
print('coffee is ready')
oj:Juice = pour_orange_juice()
print('Orange juice is ready')
print('Breakfest ready! in %s s' % int(round(time.time() - now)))