第九章作业

#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 restaurant
Star is now openning
A1 is a West restaurant
a1 is now openning
A2 is a India restaurant
a2 is now openning
A3 is a Thai restaurant
a3 is now openning
user is jin id is 16337 phone number is 10000
user is king id is 12312 phone number is 234234
user is fun id is 123123 phone number is 3232432324
hello king
user is jin id is 16337 phone number is 10000

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值