实验7

class User:
    def __init__(self,name='guest',password=111111,status=1):
        self.name=name
        self.password=password
        self.status=status
    def info(self):
        print('账户信息')
        print('用户名:',self.name)
        print('密码:',self.password)
        if self.status==1:
            print('账号状态:正常')
        if self.status==0:
            print('账号状态:异常')
    def modify_password():
        x=input('输入旧密码:')
        if x==self.password:
            y=input('输入新密码:')
            self.password=y
            print('密码修改成功!')
        else:
            x=input('密码错误,请重新输入旧密码:')
            if x==self.password:
                y=input('输入新密码:')
                self.password=y
                print('密码修改成功!')
            else:
                x=input('密码错误,请重新输入旧密码:')
                if x==self.password:
                    y=input('输入新密码:')
                    self.password=y
                    print('密码修改成功!')
                else:
                    self.status=0
                    print('账户已锁,请稍后再试')
class Admin(User):
    def __init__(self,name='admin',password=999999,status=1):
        super().__init__(name,password,status)
    def info(self):
        User.info(self)
    def reset_password(self):
        User.modify_password
    def ban_user(self):
        User._status=0
        print('账户已锁')
    def unblock_user(self):
        User._status==1
        print('账号已解封')
def main():
    x1=User()
    x1.info()
    x1.modify_password
    x1.info()
    y1=Admin()
    y1.info()
    y1.reset_password
    y1.ban_user()
    y1.unblock_user()

if __name__=='__main__':
    main()

 

posted @ 2022-06-07 19:22  周易潇  阅读(6)  评论(2编辑  收藏  举报