|
发表于 2021-5-7 00:15:37
|
显示全部楼层
本楼为最佳答案
- class Restaurant:
- '''餐馆的描述'''
- def __init__(self,restaurant_name,cuisine_type):
- self.restaurant_name=restaurant_name
- self.cuisine_type=cuisine_type
- self.number_served=0
- class IceCreamStand(Restaurant):
- def __init__(self,restaurant_name,cuisine_type,flavors):
- super().__init__(restaurant_name,cuisine_type)
- self.flavors=flavors
- def show(self):
- print('店名:',self.restaurant_name)
- print('风格:',self.cuisine_type)
- print(self.flavors)
-
- f=['apple','orange','pear']
- ice=IceCreamStand('鱼C冰淇淋店','icecream',f)
- ice.show()
复制代码
你的代码貌似缩进有问题,不知道是因为你没有用过代码模式发帖还是因为你本身缩进就错了
2构造方法要把restaurant_name,cuisine_type这两个参数加上,下边实例化的时候也要带对应的参数 |
|