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(f'{self._name}, {self._password}, {self._status}')

    def modify_password(self):
        old_password = input('输入旧密码:')
        i = 1
        while (i <= 3):
            if old_password == self._password:
                new_password = input('输入新密码:')
                print('密码修改成功')
                break
            else:
                old_password = input('密码错误,请再次输入:')
                i = i+1
                if i == 3:
                    if old_password != self._password:
                        print('账户已锁,请稍后再试')
                        break

a1 = User('Bill','123123',1)
a1.info()
a1.modify_password()
from user import User
u1 = User('Bill','123123',1)
u1.info()
u1.modify_password()

 


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

    def info(self):
        print('用户名,密码,账户状态')
        print(f'{self.name}, {self.password}, {self.status}')

    def reset_password(self):
        old_password = input('输入旧密码:')
        i = 1
        while (i <= 3):
            if old_password == self.password:
                new_password = input('输入新密码:')
                print('密码修改成功')
                break
            else:
                old_password = input('密码错误,请再次输入:')
                i = i + 1
                if i == 3:
                    if old_password != self.password:
                        print('账户已锁,请稍后再试')
                        break

    def ban_user(self):
        if self.status == 0:
            print('该账户已处于封禁状态')

    def unblock_user(self):
        if self.status == 1:
            print('该账户已解封')
from user2 import Admin
u2 = Admin('Ben','666666',1)
u2.info()
u2.unblock_user()
u2.reset_password()

 

 

posted on 2022-06-07 16:55  清橙往忆  阅读(6)  评论(1编辑  收藏  举报