截图来自<python编程:从入门到实践>
我的代码如下:
class Restaurant():
def __init__(self,restaurant_name,cuisine_type):
self.restaurant_name=restaurant_name
slef.cuisine_type=cuisine_type
self.number_served=0
def describe_restaurant(self):
print(self.restaurant_name.title() + 'is wonderful! And ' + self.cuisine_type.title + 'is the main feature.')
def open_restaurant(self):
print(self.restaurant_name.title() + 'now is opening! Welcom!')
def people_sercerd(self):
print('There were ' + str(self.number_served) + ' people have been serverd in ' + self.restaurant_name.title() + '.')
def increment_number_served(self,people_count):
self.number_served=people_count
restaurant=Restaurant("La Blue","kali")
restaurant.describe_restaurant()
restaurant.open_restaurant()
restaurant.people_sercerd()
restaurant.increment_number_served(55)
restaurant.people_sercerd()