-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrestaurant_9_2.py
36 lines (23 loc) · 950 Bytes
/
restaurant_9_2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: cp936 -*-
# 详细说明见书P142
# 创建一个餐馆的类
class Restaurant():
def __init__(self, restaurant_name, cuisine_type, open_time):
"""初始化描餐馆的属性"""
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.open_time = open_time
def describe_restaurant(self):
"""返回整洁的描述性信息"""
print("The restaurant's name is " + self.restaurant_name)
print("The cuisine_type is " + self.cuisine_type)
def open_restaurant(self):
if self.open_time >= 10:
print("The restaurant has opened.")
else:
print("The restaurant has closed.")
new_restaurant = Restaurant('Yunxi', 'Chuancai', 20)
new_restaurant.describe_restaurant()
new_restaurant.open_restaurant()
new_restaurant = Restaurant('Yunxi', 'Chuancai',20)
new_restaurant.describe_restaurant()