导入的模块:
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"{self.restaurant_name}\n{self.cuisine_type}")
def open_restaurant(self):
print(f"The restaurant {self.restaurant_name} is open. ")
class IceCreamStand(Restaurant):
def init(self,restaurant_name,cuisine_type):
super().init(restaurant_name,cuisine_type)
self.flavors = ['strawberry','watermellon','apple']
def describe_flavors(self):
for key in self.flavors:
print(key)
IceCreamStand_1 = IceCreamStand('Alice','sweet')
IceCreamStand_1.describe_flavors()
被导入:
from practice9_6 import Restaurant
strawberry
watermellon
apple
代码有些乱, 层次看不清。建议用插入代码功能重新贴一下代码
```python
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"{self.restaurant_name}\n{self.cuisine_type}")
def open_restaurant(self):
print(f"The restaurant {self.restaurant_name} is open. ")
class IceCreamStand(Restaurant):
def __init__(self,restaurant_name,cuisine_type):
super().__init__(restaurant_name,cuisine_type)
self.flavors = ['strawberry','watermellon','apple']
def describe_flavors(self):
for key in self.flavors:
print(key)
IceCreamStand_1 = IceCreamStand('Alice','sweet')
IceCreamStand_1.describe_flavors()
from practice9_6 import Restaurant
```python