Skip to content

Commit 4dbc9a7

Browse files
authored
Add files via upload
0 parents  commit 4dbc9a7

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

CoffeeMachine/main.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import menu
2+
import os
3+
4+
logo = """
5+
6+
________ __ __ ___ ___ __ __
7+
| | | |.-----.| |.----.-----.--------.-----. | |_.-----. .----.-----.' _|.' _|.-----.-----. .--------.---.-.----.| |--.|__|.-----.-----.
8+
| | | || -__|| || __| _ | | -__| | _| _ | | __| _ | _|| _|| -__| -__| | | _ | __|| || || | -__|__
9+
|________||_____||__||____|_____|__|__|__|_____| |____|_____| |____|_____|__| |__| |_____|_____| |__|__|__|___._|____||__|__||__||__|__|_____|__|
10+
11+
"""
12+
profit = 0
13+
resources = {
14+
"water":500,
15+
"milk":200,
16+
"coffee":100,
17+
}
18+
19+
def check_resources(order_ingredients):
20+
for item in order_ingredients:
21+
if order_ingredients[item] > resources[item]:
22+
print(f"Sorry! There is not enough {item}")
23+
return False
24+
return True
25+
def process_coins():
26+
print("please insert coins (only 5rs,10rs,20rs coins accepted): ")
27+
total = 0
28+
coins_five = int(input("How many 5rs coins: "))
29+
coins_ten = int(input("How many 10rs coins: "))
30+
coins_twenty = int(input("How many 20rs coins: "))
31+
total = coins_five*5 + coins_ten*10 + coins_twenty*20
32+
return total
33+
34+
def is_payment_successful(user_payment, coffee_price):
35+
if user_payment >= coffee_price:
36+
global profit
37+
profit += coffee_price
38+
change = user_payment-coffee_price
39+
print(f"Here is your Rs{change} in change.")
40+
return True
41+
else:
42+
print("Sorry that's not enough money.money refunded.")
43+
return False
44+
45+
def make_coffee(coffee_name,coffee_ingredients):
46+
for item in coffee_ingredients:
47+
resources[item] -= coffee_ingredients[item]
48+
print(f"Here is your {coffee_name} ☕... Enjoy!")
49+
50+
def coffee_machine():
51+
print(logo)
52+
choice = input(
53+
"what would you like to have? (latte/espresso/cappuccino),Type (off) to off the machine,Type (report) to get the report of the machine:\n ")
54+
os.system('cls')
55+
is_on = True
56+
while is_on:
57+
if choice == "off":
58+
is_on = False
59+
elif choice == "report":
60+
print(
61+
f"Water: {resources['water']}ml\nMilk:{resources['milk']}ml\nCoffee:{resources['coffee']}g\nMoney:Rs {profit}")
62+
else:
63+
coffee_type = menu.Menu[choice]
64+
print(f"Coffee name: {choice}\nCoffee ingredients: {coffee_type}")
65+
if check_resources(coffee_type['ingredients']):
66+
payment = process_coins()
67+
if is_payment_successful(payment, coffee_type['cost']):
68+
make_coffee(choice, coffee_type['ingredients'])
69+
coffee_machine()
70+
71+
72+
coffee_machine()
73+
74+
75+

CoffeeMachine/menu.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Menu = {
2+
"espresso":{
3+
"ingredients": {
4+
"water":50,
5+
"coffee": 18,
6+
},
7+
"cost": 100,
8+
},
9+
10+
"latte": {
11+
"ingredients": {
12+
"water": 200,
13+
"milk": 100,
14+
"coffee": 24,
15+
},
16+
"cost": 150,
17+
},
18+
19+
"cappuccino": {
20+
"ingredients": {
21+
"water": 250,
22+
"milk": 100,
23+
"coffee": 24,
24+
},
25+
"cost": 200,
26+
},
27+
28+
29+
}

0 commit comments

Comments
 (0)