实验七

class user:
    def __init__(self,name='guest',password=111111,status=1):
        self.name=name
        self.password=password
        self.status=status
    def info(self):
        if self.status==1:
            print(f'用户名:{self.name},密码:{self.password},账号状态正常')
        else:
            print(f'用户名:{self.name},密码:{self.password},账号处于封禁状态')
    def modify_password(self):
        for i in range(3):
            x=eval(input('输入旧密码'))
            if x==self.password:
                self.password=eval(input('输入新密码'))
                print('密码修改成功')
                break
            else:
                print('密码错误')
                if i==2:
                    print('账号已锁,请稍后再试')
class admin(user):
    def __init__(self,name='admin',password=999999,status=1):
        self.name=name
        self.password=password
        self.status=status
    def reset_password(self,user):
        user.password=eval(input('输入新密码'))
    def ban_user(self,user):
        user.status=0
    def unlock_user(self,user):
        user.status=1
u1=user()
u1.info()
u1.modify_password()
a1=admin()
a1.info()
a1.reset_password(u1)
a1.ban_user(u1)
print(u1.status)
a1.unlock_user(u1)
print(u1.status)

 

posted @ 2022-06-07 21:25  雷建彬  阅读(7)  评论(0编辑  收藏  举报