class Restaurant():
def __init__(self,restaurant_name,cuisine_type,*a):
self.name = restaurant_name
self.type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
print('餐厅的名字是:'+self.name)
print('餐厅的类型是:'+self.type)
def open_restaurant(self):
print('餐厅正在营业')
def set_name_served(self,renshu):
self.number_served = self.number_served + renshu
def number(self):
if self.number_served == 0:
print('只有'+str(self.number_served)+'人在'+self.name+'就餐!')
else:
print('已经有'+str(self.number_served)+'人在'+self.name+'就餐了!')
class Icecreamstand(Restaurant):
def __init__(self,restaurant_name,cuisine_type,*a):
super().__init__(restaurant_name,cuisine_type,*a)
self.flavors = str(a)
def flavor(self):
return self.name+'的冰淇淋种类有:'+str(self.flavors)
d = Restaurant('夜半食堂','中式餐饮')
d.describe_restaurant()
c = Icecreamstand('冰淇淋小店','甜品店','草莓味','西瓜味','橘子味','桃子味')
print(c.flavor())
c.describe_restaurant()
|