练习题-类-给属性指定默认值

练习题-类-给属性指定默认值_第1张图片

截图来自

我的代码如下:

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()

你可能感兴趣的:(练习题-类-给属性指定默认值)