9-1 餐馆 :创建一个名为Restaurant的类,其方法__init__() 设置两个属性:restaurant_name 和cuisine_type 。创建一个名为describe_restaurant() 的方法和一个名为open_restaurant() 的方法,其中前者打印前述两项信息,而后者打印一条消息,指出餐馆正在营业。 根据这个类创建一个名为restaurant 的实例,分别打印其两个属性,再调用前述两个方法。
9-2 三家餐馆 :根据你为完成练习9-1而编写的类创建三个实例,并对每个实例调用方法describe_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 restaurant's name is "+self.restaurant_name+".") print("The cuisine type of it is "+self.cuisine_type+".") def open_restaurant(self): print("The restaurant is opening.")
输出结果

9-4 就餐人数 :在为完成练习9-1而编写的程序中,添加一个名为number_served 的属性,并将其默认值设置为0。根据这个类创建一个名为restaurant的实例;打印有多少人在这家餐馆就餐过,然后修改这个值并再次打印它。
添加一个名为set_number_served()的方法,它让你能够设置就餐人数。调