实验7

实验任务5
 count=0
    def __init__(self,name='gest',password=111111,status=1):
        User.count+=1
        self.name=name
        self.password=password
        self.status=status
    def info(self):
        print(self.name+','+str(self.password)+','+'账户正常')
    def modify_password(self):
        s=input('输入旧密码:')
        if(s==str(self.password)):
            s1=input('输入新密码:')
            self.password=s1
            print('密码修改成功!')
        else:
            s=input('输入旧密码:')
            if(s==str(self.password)):
                s1=input('输入新密码:')
                self.password=s1
                print('密码修改成功!')
            else:
                s=input('输入旧密码:')
                if(s==str(self.password)):
                    s1=input('输入新密码:')
                    self.password=s1
                    print('密码修改成功!')
                else:
                    print('账户已锁,请稍后再试')
                
    @classmethod
    def show_count(cls):
        print('用户总数:'+str(User.count))
u1=User()
u1.info()
u1.modify_password()
u1.info()
u2=User('a001','777')
u2.info()
User.show_count()

 



class User:
    count=0
    def __init__(self,name='gest',password=111111,status=1): 
        User.count+=1
        self.name=name
        self.password=password
        self.status=status
    def __del__(self,name='gest',password=111111,status=1):
        User.count-=1
    def info(self):
         if(self.status==1):
             print(self.name+','+str(self.password)+','+'账户正常')
             print('管理员账户')
         else:
             print(self.name+','+str(self.password)+','+'账户被封禁')
    @classmethod
    def show_count(cls):
        print('用户总数:'+str(User.count))

class Admin(User):
     def __init__(self,name,password=999999,status=1):
         super().__init__(name,password,status)
     def info(self):
        if(self.status==1):
             print(self.name+','+str(self.password)+','+'账户正常')
        else:
            print(self.name+','+str(self.password)+','+'账户被封禁')

     def ban_user(self,x):
         x.status=0
     def unblock_user(self,x):
         x.status=1
     def reset_password(self,x):
         x.password=input('重置密码:')
         
         
u1 = User()
u1.info()

admin1 = Admin('x001')

 

 

 


 

posted @ 2022-06-05 16:10  202183360008仲苏洋  阅读(26)  评论(1编辑  收藏  举报