class User():
def __init__(self,first_name,last_name,other):
self.first_name = first_name
self.last_name = last_name
self.other = other
self.login_attempts = 0
def describe_user(self):
print(self.first_name,self.last_name,self.other)
def greet_user(self):
print('Hello,'+ self.first_name + ' ' + self.last_name)
def increment_login_attempts(self):
self.login_attempts += 1
def reset_login_attempts(self):
self.login_attempts = 0
class Admin(User):
def __init__(self,first_name,last_name,other):
super().__init__(first_name,last_name,other)
self.privileges = Privileges()
class Privileges():
def __init__(self):
self.privileges = ['can add post', 'caon delete post', 'an ban user']
def show_privileges(self):
for show_privileges in self.privileges:
print(show_privileges)
admin = Admin('张','三','延安')
admin.describe_user()
admin.privileges.show_privileges()
9-8
最新推荐文章于 2021-04-02 00:34:53 发布