创建一个名为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 is: '+self.restaurant_name.title()+' .')
print('The type is: '+self.cuisine_type.title()+' .')
def open_restaurant(self):
print(self.restaurant_name.title()+' is opening.')
class Restaurant():
my_restaurant=Restaurant('Haidilao','Huoguo')
print(my_restaurant.restaurant_name)
print(my_restaurant.cuisine_type)
my_restaurant.describe_restaurant()
my_restaurant.open_restaurant()