实验7

class Users:

    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(self.name, ',', self.password, ',', '账户正常')
        else:
            print('封禁账号')
            self.status = 0

    def modify_password(self):
        if self.status == 1:
            for i in range(0,3):
                if self.password == input('输入旧密码:'):
                    self.password = input('输入新密码:')
                    break
                else:
                    i += 1
                if i == 2:
                    print('账户已锁,请稍后再试')
                    Users.status = 0
from user import Users

class Admin(Users):

    def __init__(self, name='admin', password='999999', status=1):
        super().__init__(name, password, status)

    def info(self):
        super().info()

    def ban_user(self, users):
        users.status = 0

    def unblock_user(self, users):
        users.status = 1

    def reset_password(self, users):
        users.password = input('重置密码:')

 

posted @ 2022-06-07 23:48  严成娜  阅读(4)  评论(0编辑  收藏  举报