python简单点餐系统
代码】python简单点餐系统。
·
import random
msg = """**********欢迎使用XXX点餐系统************
1.点餐
2.订座
0.退出系统
****************************************************
"""
#菜品总列表
Dish_info = [
{'编号': '1', '菜名': '西红柿炒蛋', '价格': '10', '分类': '炒菜'},
{'编号': '2', '菜名': '扬州炒饭 ', '价格': '8', '分类': '主食'},
{'编号': '3', '菜名': '煎饺 ', '价格': '13', '分类': '主食'},
{'编号': '4', '菜名': '青椒肉丝 ', '价格': '18', '分类': '炒菜'}
]
#已点菜品列表
Order_Info = []
#打印菜品总列表
def Show_Dish_Msg():
print('今日菜单已经上架!')
print('编号\t\t菜名\t\t\t\t价格\t\t分类')
for dish in Dish_info:
print(
dish['编号'] + '\t\t' +
dish['菜名'] + '\t\t' +
str(dish['价格']) + '\t\t' +
dish['分类'] + '\t\t'
)
#点菜
def Order_Menu():
while True:
order = input("请输入菜品编号点菜:")
for dish in Dish_info:
if order == dish['编号']:
Order_Info.append(dish)
Show_Order_Menu()
out_or_continue = input("是否继续点菜?(是/否)")
print('='*100)
if out_or_continue == '是':
continue
elif out_or_continue == '否':
break
#打印已点菜品列表
def Show_Order_Menu():
print('已点菜:')
print('编号\t\t菜名\t\t\t\t价格\t\t分类')
for show_order in Order_Info:
print(
show_order['编号'] + '\t\t' +
show_order['菜名'] + '\t\t' +
str(show_order['价格']) + '\t\t' +
show_order['分类'] + '\t\t'
)
print('='*100)
#删除已点菜品
def Del_Order_Menu():
Show_Order_Menu()
del_order_menu = input("请输入您想移除的菜品编号:")
for del_order in Order_Info:
if del_order_menu == del_order['编号']:
Order_Info.remove(del_order)
print("已移除!")
Show_Order_Menu()
break
#查找菜品
def Dish_Find():
print('查找菜品')
print('请选择以下方式:\n1.根据菜名查找\n2.根据分类查找(例如:炒菜/主食)')
method_of_find = input("请输入您想要的查询方式:")
if method_of_find == '1':
dish_name = input("请输入您想查询的菜名:")
print('编号\t\t菜名\t\t\t\t价格\t\t分类')
for dish_info in Dish_info:
if dish_name == dish_info['菜名']:
print(
dish_info['编号'] + '\t\t' +
dish_info['菜名'] + '\t\t' +
str(dish_info['价格']) + '\t\t' +
dish_info['分类'] + '\t\t'
)
break
else:
print("查无此菜品!请尽请期待!")
elif method_of_find == '2':
dish_classify = input("请输入您想查询的分类:")
print('编号\t\t菜名\t\t\t\t价格\t\t分类')
for dish_info in Dish_info:
if dish_classify == dish_info['分类']:
print(
dish_info['编号'] + '\t\t' +
dish_info['菜名'] + '\t\t' +
str(dish_info['价格']) + '\t\t' +
dish_info['分类'] + '\t\t'
)
else:
print("无效操作!")
#结算
def Final_Statement():
total_price = 0
for price_order in Order_Info:
total_price += int(price_order['价格'])
print(f" 小计{total_price}元")
Order_Info.clear()
#订座
def Reserve_Seat():
human_num = int(input("请问您有几位?"))
seat = random.randint(5, 13)
if human_num > seat:
print("对不起,座位不够!具体情况请询问客服!")
else:
print("有座位!")
#退出
def Exit():
Show_Order_Menu()
print("下次再见!")
#点餐系统
def System_Of_Order():
msg_order = """
******************请点餐*******************
1.添加菜品
2.显示已点菜品列表
3.删除菜品
4.查找菜品
0.返回并结算
*******************************************
"""
while True:
print(msg_order)
operation = input("请输入您想进行的操作:")
if operation == '1':
Order_Menu()
elif operation == '2':
Show_Order_Menu()
elif operation == '3':
Del_Order_Menu()
elif operation == '4':
Dish_Find()
elif operation == '0':
Final_Statement()
break
else:
print("无效操作!")
if __name__ == '__main__':
while True:
Show_Dish_Msg()
print(msg)
hello = input("请输入您想进行的操作:")
if hello == '1':
System_Of_Order()
elif hello == '2':
Reserve_Seat()
elif hello == '0':
Exit()
break
else:
print("无效操作!")
更多推荐
已为社区贡献1条内容
所有评论(0)