# -*- conding:utf-8 -*-
class User:
    def __init__(self,first_name,last_name,age,sex,phone,login_attempts = 0):
        self.first_name = first_name
        self.last_name = last_name
        self.age = age
        self.sex = sex
        self.phone = phone
        self.login_attempts=login_attempts
    def describe_user(self):
        print('我叫 %s  %s,今年%d岁,我的电话是%s'%(self.first_name,self.last_name,self.age,self.phone))
    def greet_user(self):
        print('尊敬的%s,您好!'%self.first_name)
     #递增登录次数
    def increment_login_attempts(self):
        self.login_attempts += 1
        print('%s的登录次数为:%d'%(self.first_name,self.login_attempts))
     #重置登录次数
    def reset_login_attempts(self):
        self.login_attempts = 0
        print('%s的登录次数为:%d' % (self.first_name, self.login_attempts))
if __name__ == '__main__':
    joe = User('Joe','Black',20,'','18011123333')
    #joe.describe_user()
    # joe.greet_user()
    joe.increment_login_attempts()
    joe.increment_login_attempts()
    joe.increment_login_attempts()
    joe.increment_login_attempts()
    joe.reset_login_attempts()

 

相关文章:

  • 2021-08-18
  • 2021-06-13
  • 2021-08-26
  • 2021-11-26
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-04-21
  • 2021-11-14
  • 2022-12-23
相关资源
相似解决方案