高级编程技术第九次作业

9-1 餐馆

class Restaurant():
	"""the restaurant"""
	
	def __init__(self, restaurant_name, cuisine_type):
		"""Initialize the restaurant"""
		self.restaurant_name = restaurant_name
		self.cuisine_type = cuisine_type
		
	def describe_restaurant(self):
		"""Display a summary of the restaurant"""
		print("name: " + self.restaurant_name)
		print("cuisine type: " + self.cuisine_type)
		
	def open_restaurant(self):
		"""the restaurant is open"""
		print("The restaurant is open.")
		
		
restaurant = Restaurant("Hidilao hot pot", "hot pot")
print(restaurant.restaurant_name)
print(restaurant.cuisine_type)
restaurant.describe_restaurant()
restaurant.open_restaurant()

9-4 就餐人数

class Restaurant():
	"""the restaurant"""
	
	def __init__(self, restaurant_name, cuisine_type):
		"""Initialize the restaurant"""
		self.restaurant_name = restaurant_name
		self.cuisine_type = cuisine_type
		self.number_served = 0
		
	def describe_restaurant(self):
		"""Display a summary of the restaurant"""
		print("name: " + self.restaurant_name)
		print("cuisine type: " + self.cuisine_type)
		print("number served: " + str(self.number_served))
		
	def open_restaurant(self):
		"""the restaurant is open"""
		print("The restaurant is open.")
		
	def set_number_served(self, new_number):
		"""set number served"""
		self.number_served = new_number
		
	def increament_number_served(self, additional_served):
		"""increament number served"""
		self.number_served += additional_served
		

restaurant = Restaurant("Hidilao hot pot", "hot pot")
print(restaurant.restaurant_name)
print(restaurant.cuisine_type)
print(restaurant.number_served)
restaurant.describe_restaurant()
restaurant.open_restaurant()
restaurant.set_number_served(10)
print(restaurant.number_served)
restaurant.increament_number_served(5)
print(restaurant.number_served)

9-6 冰激凌小店

class Restaurant():
	"""the restaurant"""
	
	def __init__(self, restaurant_name, cuisine_type):
		"""Initialize the restaurant"""
		self.restaurant_name = restaurant_name
		self.cuisine_type = cuisine_type
		
	def describe_restaurant(self):
		"""Display a summary of the restaurant"""
		print("name: " + self.restaurant_name)
		print("cuisine type: " + self.cuisine_type)
		
	def open_restaurant(self):
		"""the restaurant is open"""
		print("The restaurant is open.")


class IceCreamStand(Restaurant):
	"""A class representing a restaurant"""
	
	def __init__(self, restaurant_name, cuisine_type = "ice_cream"):
		"""Initialize an ice cream stand"""
		super().__init__(restaurant_name, cuisine_type)
		flavors = []
		
	def show_flavors(self):
		"""show flavors"""
		for flavor in self.flavors:
			print(flavor)
			
			
ice_cream_stand = IceCreamStand("ice cream stand")
ice_cream_stand.flavors = ['vanilla', 'chocolate', 'black cherry']
ice_cream_stand.describe_restaurant()
ice_cream_stand.open_restaurant()
ice_cream_stand.show_flavors()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值