实验七 类和模块

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(self.name,self.password,'用户状态正常')
        elif self.status==0:
            print(self.name,self.password,'用户状态封禁')
    def modify_password(self):
        sum1=0
        while sum1<=3:
            n=input('Enter password:')
            if n==self.password:
                m=input('Enter new password:')
                self.password=m
                print('密码修改成功')
                break
            
            print('密码错误,重新输入')
            sum1+=1
        else:
            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):
        n=input()
        self.password=n
    def ban_user(self):
        self.status=0
    def unblock_user(self):
        self.status=1

 

posted @ 2022-06-07 11:50  Embeddd  阅读(15)  评论(2编辑  收藏  举报