创建一个名为Restaurant 的类,其方法__init__() 设置两个属性:restaurant_name 和cuisine_type 。创建一个名 为describe_restaurant() 的方法和一个名为open_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("The name of this restaurant is "+self.restaurant_name.title())
print("The cuisine type is "+self.cuisine_type.title())
def open_restaurant(self):
print("The restaurant is open!")
res = Restaurant('good', 'ok')
print(res.restaurant_name)
print(res.cuisine_type)
res.describe_restaurant()
res.open_restaurant()