创建一个名为Restaurant的类: 其构造方法_init_()设置两个属性:restaurant_name和cuisine_type。创建一个名为describe_restaurant()的方法,打印前述两项信息 创建一个名为open_restaurant()的方法,打印一条消息,指出餐馆正在营业。
时间: 2024-03-16 14:42:27 浏览: 99
好的,以下是符合您要求的Python代码:
```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"The restaurant's name is {self.restaurant_name}.")
print(f"The cuisine type is {self.cuisine_type}.")
def open_restaurant(self):
print("The restaurant is now open!")
```
您可以通过以下代码来测试上述类:
```python
restaurant = Restaurant("Pizza Hut", "Italian")
restaurant.describe_restaurant()
restaurant.open_restaurant()
```
输出结果为:
```
The restaurant's name is Pizza Hut.
The cuisine type is Italian.
The restaurant is now open!
```
阅读全文