Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User:
- def __init__(self, first, last, attempts=0):
- self.first_name = first
- self.last_name = last
- self.login_attempts = attempts
- def describe_user(self):
- print(f'Nama depan : {self.first_name}\nNama belakang : {self.last_name}')
- def greet_user(self):
- print(f'Hi, welcome {self.first_name} {self.last_name}')
- def increment_login_attempts(self):
- self.login_attempts += 1
- def reset_login_attempts(self, number):
- self.login_attempts = number
- user1 = User('Budi', 'Setiawan')
- user1.describe_user()
- user1.greet_user()
- for a in range (3):
- user1.increment_login_attempts()
- user1.login_attempts = 0
- class Admin(User):
- def __init__(self, first, last, attempts=0):
- super().__init__(first, last, attempts)
- #self.privileges = ['can add post', 'can delete post', 'can ban user', '', '']
- self.privileges = Privileges()
- '''
- def show_privileges(self):
- print('privileges : ')
- counter = 1
- for privileges in self.privileges:
- print(counter, privileges.title())
- counter = counter + 1
- '''
- class Privileges:
- def __init__(self):
- self.privileges = ['can add post', 'can delete post', 'can ban user', 'can view any posts', 'can add new user']
- def show_privileges(self):
- print('privileges : ')
- counter = 1
- for privileges in self.privileges:
- print(counter, privileges.title())
- counter = counter + 1
- userAdmin = Admin('A', 'B')
- userAdmin.privileges.show_privileges()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement