|
发表于 2020-9-16 20:31:24
|
显示全部楼层
- class Restaurant():
- """class of restaurant"""
- def __init__(self,restaurant_name,cuisine_type):
- self.restaurant_name = restaurant_name
- self.cuisine_type = cuisine_type
-
- def describe_restaurant(self):
- print("Restaurant's name is " + self.restaurant_name)
- print("Restaurant's type is " + self.cuisine_type)
-
- def open_restaurant(self):
- print('This restaurant is openning.')
-
- class IceCreamStand(Restaurant):
-
- def __init__(self,restaurant_name,cuisine_type):
-
- super().__init__(restaurant_name,cuisine_type)
- self.flavors = ['cheese']
-
- def show_flavors(self):
- print(self.flavors)
-
- def flavors(self,flavors_list):
- self.flavors.append(flavors_list)
-
-
- M = IceCreamStand('Mc','western')
- M.flavors()
- M.show_flavors()
复制代码 |
|