9-1餐馆:1.创建一个名为Restaurant的类,其方法__init__()设置两个属性:restaurant_name和cuisine_type.创建一个名为describe_restaurant()方法和一个名为open_restaurant()的方法,其中前者打印前述两项信息,而后者打印一条消息,指出餐馆正在营业.
2.根据这个类创建一个名为restaurant的实例,分别打印其两个属性,再调用前述两个方法。
class Restaurant():
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
print("\n这家餐馆的名字是" + self.restaurant_name.title() + ",主打的菜系是" + self.cuisine_type + '。')
def open_restaurant(self):
print("This restaurant is opening.")
restaurant = Restaurant('四方阁', '川菜')
restaurant.describe_restaurant()
restaurant.open_restaurant()
restaurant_1 = Restaurant('云水谣', '粤菜')
restaurant_1.describe_restaurant()
restaurant_1.open_restaurant()