-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample07.py
More file actions
39 lines (29 loc) · 786 Bytes
/
example07.py
File metadata and controls
39 lines (29 loc) · 786 Bytes
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
from food import Beverage
from meal import Meal
from person import Person
def main():
# Create an adult and a child
adult = Person("Dana", age=30)
child = Person("Eli", age=12)
# Create beverages
lemonade = Beverage("Lemonade", contains_alcohol=False)
wine = Beverage("Wine", contains_alcohol=True)
# Wash hands before drinking
adult.wash_hands()
child.wash_hands()
# Build and prep a meal
meal = Meal([lemonade, wine])
meal.prep()
# Eat the meal (round-robin)
meal.eat([adult, child])
# Show final status
adult.show_status()
child.show_status()
# JSON snapshots
adult.to_json()
child.to_json()
lemonade.to_json()
wine.to_json()
meal.to_json()
if __name__ == "__main__":
main()