料理を注文する
メニューの印刷
デジタル注文
点を表示
費用を計算する
デジタル注文
点を表示
費用を計算する
"""order food"""
# the food name and the price
menu = [['done and exit', ''], ['dan chao fan', 8], ['hui guo rou', 14], ['qing zheng yu', 18]]
def print_menu(menu):
""" print the sequence and the food name and the price. """
menu_len = len(menu)
for i in range(0, menu_len):
print "%d %s %s" % (i, menu[i][0].ljust(20), menu[i][1])
def get_orders():
""" get the order num. """
print
orders = []
while True:
num = raw_input('input you choice:')
if num == '0':
return orders
else:
orders.append(int(num))
def print_orders(orders, menu):
"""print customer order list"""
print
print "you have order:"
for i in orders:
print menu[i][0], menu[i][1]
def compute_cost(orders, menu):
"""print the total cost of order foods"""
print
cost = 0
for i in orders:
cost += menu[i][1]
print "the total cost is: %s" % cost
print_menu(menu)
orders = get_orders()
print_orders(orders, menu)
compute_cost(orders, menu)