|
发表于 2021-8-7 15:14:20
|
显示全部楼层
本楼为最佳答案
你这属性和方法都叫flavors,程序也很迷惑
- class Restaurant:
- def __init__(self,restaurant_name,cuisine_type):
- self.restaurant_name=restaurant_name
- self.cuisine_type=cuisine_type
- def describe_restaurant(self):
- print(f' the restaurant name is {self.restaurant_name}')
- print(f'this restaurant sales {self.cuisine_type} food')
- def open_restaurant(self):
- print('the restaurant is opening')
- class Icecreamstand(Restaurant):
- def __init__(self,restaurant_name,cuisine_type):
- super().__init__(restaurant_name,cuisine_type)
- self.flavors1=['hu','df''jk']
-
- def flavors(self):
- print(f'there are flavors as bolew:{self.flavors1}')
-
- eg=Icecreamstand('holiwood','icecream')
- eg.describe_restaurant()
- eg.open_restaurant()
- eg.flavors()
复制代码 |
|