Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.4 kB
5
Indexable
Never
class Users:
	def __init__(self, first_name, last_name, age, location, gender,\
login_attempts=0):
		self.first_name = first_name.title()
		self.last_name = last_name.title()
		self.age = age
		self.location = location.title()
		self.gender = gender.title()
		self.login_attempts = login_attempts
	def describe_user(self):
		print(f"{self.first_name} {self.last_name}")
		print(f"\t-of {self.gender} gender.")
		print(f"\t-Age is {self.age}.")
		print(f"\t-Lives in {self.location}.")
		print(f"\t-You attempted logins {self.login_attempts} times.\n")
	def greet_user(self):
		print(f"Welcome, {self.first_name}")
	def increment_login_attempts(self):
		self.login_attempts += 1
	def reset_login_attempts(self):
		self.login_attempts = 0
		
class Admin(Users):
	def __init__(self,first_name,last_name, age, location, gender,\
login_attempts=0 ):
		super().__init__(first_name,last_name, age, location, gender,\
login_attempts=0)
		self.privileges = Privileges()
		
class Privileges():
	def __init__(self, privleges=[]):
		self.privleges = privleges
	
	def show_privileges(self):
		print(f"These are the Admin privileges: ")
		for privilege in self.privleges:
			print(f"\t-{privilege}")

amit = Admin('amit','kumar',32,'mumbai','male',4)
amit.privileges = ['can login', 'can approve', 'can reject']
amit.show_privileges()