Created
June 8, 2020 21:58
-
-
Save jenheller/2e4f930c0776e3a28ed406a32d162846 to your computer and use it in GitHub Desktop.
Coffe Bot Version 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from utils import print_message, get_size, order_latte | |
def coffee_bot(): | |
print('Welcome to the cafe!') | |
order_drink = 'y' | |
drinks = [] | |
while order_drink == 'y': | |
size = get_size() | |
drink_type = get_drink_type() | |
temp = hot_or_iced() | |
drink = '{} {} {}'.format(size, temp, drink_type) | |
print('Alright, that\'s one {}!'.format(drink)) | |
drinks.append(drink) | |
while True: | |
order_drink = input("Would you like to order another drink? (y/n) \n> ") | |
if order_drink == 'y' or order_drink == 'n': | |
break | |
print("Okay, so I have:") | |
for drink in drinks: | |
print("- one", drink) | |
name = input('Can I get your name please? \n> ') | |
print('Thanks, {}! Your order will be ready shortly.'.format(name)) | |
def get_drink_type(): | |
res = input('What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n[d] Chai \n> ') | |
if res == 'a': | |
return 'brewed coffee' | |
elif res == 'b': | |
return order_mocha() | |
elif res == 'c': | |
return order_latte() | |
elif res == 'd': | |
return 'chai' | |
else: | |
print_message() | |
return get_drink_type() | |
# Define new functions here! | |
def hot_or_iced(): | |
while True: | |
res=input("Would you like your drink hot or ided? \n[a] Hot \n[b] Iced\n> ") | |
if res == 'a': | |
return 'hot' | |
elif res == 'b': | |
return 'iced' | |
print_message() | |
def order_mocha(): | |
while True: | |
res=input("Would you like to try our limited-edition peppermint mocha? \n[a] Sure! \n[b] Maybe next time! \n> ") | |
if res == 'a': | |
return 'peppermint mocha' | |
elif res == 'b': | |
return 'mocha' | |
print_message() | |
coffee_bot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_message(): | |
print('I\'m sorry, I did not understand your selection. Please enter the corresponding letter for your response.') | |
def get_size(): | |
res = input('What size drink can I get for you? \n[a] Small \n[b] Medium \n[c] Large \n> ') | |
if res == 'a': | |
return 'small' | |
elif res == 'b': | |
return 'medium' | |
elif res == 'c': | |
return 'large' | |
else: | |
print_message() | |
return get_size() | |
def order_latte(): | |
res = input('What kind of milk would you like in your latte? \n[a] 2% milk \n[b] Non-fat milk \n[c] Soy milk \n> ') | |
if res == 'a': | |
return 'latte' | |
elif res == 'b': | |
return 'non-fat latte' | |
elif res == 'c': | |
return 'soy latte' | |
else: | |
print_message() | |
return order_latte() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment