练习9-2:三家餐馆 根据为完成练习9-1而编写的类创建三个实例,并对每个
实例调用方法describe_restaurant() 。
class Restaurant:
def __init__(self, restaurand_name, cuisine_type):
self.restaurant_name = restaurand_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
print(f"这个餐馆的名字是{self.restaurant_name},菜系是{self.cuisine_type}")
def open_restaurant(self):
print(f"{self.restaurant_name}餐馆正在营业!")
restaurant = Restaurant('好运来', '东北菜')
jp_restaurant = Restaurant('深夜食堂', '日式料理')
fc_restaurant = Restaurant('浪漫巴黎', '法式西餐')
restaurant.describe_restaurant()
restaurant.open_restaurant()
jp_restaurant.describe_restaurant()
jp_restaurant.open_restaurant()
fc_restaurant.describe_restaurant()
fc_restaurant.open_restaurant()
这个餐馆的名字是好运来,菜系是东北菜
好运来餐馆正在营业!
这个餐馆的名字是深夜食堂,菜系是日式料理
深夜食堂餐馆正在营业!
这个餐馆的名字是浪漫巴黎,菜系是法式西餐
浪漫巴黎餐馆正在营业!
进程已结束,退出代码0