您的位置:首页 > 其它

第九章作业

2018-04-08 23:36 169 查看
#9-1
class Restaurant():
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name=restaurant_name
self.cuisine_type=cuisine_type
def discribe(self):
print(self.restaurant_name.title()+' is a '+self.cuisine_type.title()+' restaurant')
def openrestaurant(self):
print(self.restaurant_name+' is now openning')
restaurant=Restaurant('Star','Chinese')
restaurant.discribe()
restaurant.openrestaurant()

#9-2
a1=Restaurant('a1','west')
a2=Restaurant('a2','india')
a3=Restaurant('a3','Thai')
a1.discribe()
a1.openrestaurant()
a2.discribe()
a2.openrestaurant()
a3.discribe()
a3.openrestaurant()

#9-3
class user():
def __init__(self,name, id , phone):
self.name=name
self.id=id
self.phone=phone
def discribe_user(self):
print('user is '+self.name+' id is '+str(self.id)+' phone number is '+str(self.phone))
def greet_user(self):
print('hello '+self.name)
user1=user('jin',16337,10000)
user2=user('king',12312,234234)
user3=user('fun',123123,3232432324)
user1.discribe_user()
user2.discribe_user()
user3.discribe_user()
user2.greet_user()
user1.discribe_user()
Star is a Chinese restaurantStar is now openningA1 is a West restauranta1 is now openningA2 is a India restauranta2 is now openningA3 is a Thai restauranta3 is now openninguser is jin id is 16337 phone number is 10000user is king id is 12312 phone number is 234234user is fun id is 123123 phone number is 3232432324hello kinguser is jin id is 16337 phone number is 10000
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: