书籍练习题

class Restaurant:
    def __init__(self,restaurant_name,cuisine_type,number_served=7):
        self.resraurant_name=restaurant_name
        self.cuisine_type=cuisine_type
        self.number_served=number_served
    def describe_restaurant(self):
        print('我的餐馆叫:%s'.ljust(3)%self.resraurant_name)
        print("我的菜肴类型是:%s"%self.cuisine_type)
        print("有【%s】人【%s】就餐过"%(self.number_served,self.resraurant_name))
    def open_restaurant(self):
        print("%s正在营业"%self.resraurant_name)
    def set_number_served(self,full):
        self.number_served=full
    def increment_number(self,up):
        self.number_served+=up


class User:
    def __init__(self,first_name,last_name,login_attempts):
        self.first_name=first_name
        self.last_name=last_name
        self.login_attempts=login_attempts
    def describe_user(self):
        print("first_name:%s\nlast_name:%s"%(self.first_name,self.last_name))
    def greet_user(self):
        print("hello,welcome to your word!")
    def increment_login_attempts(self):
        self.login_attempts+=1
    def reset_login_attempts(self):
        self.login_attempts=0

 

posted @ 2020-04-21 17:21  轰天雷  阅读(96)  评论(0编辑  收藏  举报