高级编程作业 第九章
2018-04-06 19:17
435 查看
#9.1 class Restaurant(): def __init__(self,name,_type): self.name = name self._type = _type self.num = 0 def des_res(self): print("Resturant's name: "+self.name+"\ncuisine type: "+self._type) def open_res(self): print("The resturant is open") def set_num(self,nums): self.num = nums def incre_num(self,nums): self.num += nums restaurant = Restaurant("LZLM","noodle") print(restaurant.name+' '+restaurant._type) restaurant.des_res() restaurant.open_res() #9.2 rest_1 = Restaurant("McDonald","fast food") rest_2 = Restaurant("mxgjrj","Mexico's") rest_1.des_res() rest_2.des_res() #9.4 rest_3 = Restaurant("CF","Yuecai") print("There are "+str(rest_3.num)+" people") rest_3.set_num(100) print("There are "+str(rest_3.num)+" people") rest_3.incre_num(6) print("There are "+str(rest_3.num)+" people") #9.6 class IceCream(Restaurant): def __init__(self,name,_type,names): super().__init__(name,_type) self.flavors = names def IC_show(self): print("there are these ics cream: ") print(self.flavors) flavor = ['Apple','Banana','Orange','Watermelon'] ice_store = IceCream('SHA','Cream',flavor) ice_store.des_res() ice_store.IC_show()模板
hw_8_restaurant.pyclass Restaurant():
def __init__(self,name,_type):
self.name = name
self._type = _type
self.num = 0
def des_res(self):
print("Resturant's name: "+self.name+"\ncuisine type: "+self._type)
def open_res(self):
print("The resturant is open")
def set_num(self,nums):
self.num = nums
def incre_num(self,nums):
self.num += nums实例from hw_8_restaurant import Restaurant
restaurant = Restaurant("LZLM","noodle")
print(restaurant.name+' '+restaurant._type)
restaurant.des_res()
restaurant.open_res()
restaurant.set_num(100)
print("There are "+str(restaurant.num)+" people")
restaurant.incre_num(6)
print("There are "+str(restaurant.num)+" people")
相关文章推荐
- 高级编程 python 第九章作业
- 高级编程作业第十章
- Boolan C++面向对象高级编程(上)第一周作业
- 2018.4.2 高级编程作业
- 高级编程作业 3.1-3.8
- 高级编程作业 4.1-4.11
- 高级编程 python 第八章作业
- 高级编程作业第8章
- ASPNET安全性高级编程 第九章 窗体身份验证
- 第五次高级编程作业
- 2018.3.5 高级编程作业
- 高级编程作业 python 第十章作业
- 高级编程 python 第四章作业
- Internet高级编程作业:用pipe, fork实现popen
- 2018.3.14 高级编程作业
- 高级编程 python 第六章作业
- 高级编程作业——6章
- 高级编程作业 7章
- 2018.3.28 高级编程作业
- 廖雪峰《python3基础教程》读书笔记——第九章 面向对象高级编程