#coding:utf-8
#弁当の購入
import math
Bento = dict([('唐揚げ弁当',450), ("日替わり弁当",500),("とんかつ弁当",450),("チキン南蛮弁当",450)])
sidemenu = dict(カツ丼=450,ソースカツ丼=450,ホットドック=200,焼きそばパン=250)
Bento.update(sidemenu)
mycart ={}
def choose():
print('''
1: 弁当一覧
2: 弁当をカートに入れ
3: カートを確認
4: 選んだ品目を削除
5: 購入個数を変更
6: レジに進み
7: おわり
''')
while True:
choose()
opt = input("オプションを選んでください: ")
if opt in ['1','1']:
for x in Bento:
print(f"{x} : {Bento[x]}円")
elif opt in ['2','2']:
print("カートに弁当を入れる")
name = input("弁当の名前を: ")
if name in Bento:
number = int(input("個数を: "))
mycart[name] = number
print(f'カードに{name}を{number}個入れた。')
elif opt in ['3','3']:
for key in mycart:
print(f"{key} : {mycart[key]} 個")
elif opt in ['4','4']:
print("選んだ品目を削除する。")
name = input("弁当の名前を: ")
if name in mycart:
mycart.pop(name)
print(f"{name}を削除した。")
else:
print(f"カートには{name}ない。")
elif opt in ['5','5']:
print(" 購入個数を変更")
name = input("弁当の名前を: ")
if name in mycart:
print(f"元の個数:{mycart[name]}")
x = int(input("変更したい個数: "))
mycart[name] = x
print(f"{name}を{x}個に変更した。")
else:
print(f"カートには{name}ない。")
elif opt in ['6','6']:
total = 0
for item in mycart:
if item in Bento:
if item == "焼きそばパン":
total += math.floor(mycart[item]/2)*400 + (mycart[item]%2)*Bento[item]
else:
total += mycart[item]*Bento[item]
print(f"総額={total}円")
elif opt in ['7','7']:
print("ありがとうございます。")
break