-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.py
66 lines (53 loc) · 2.06 KB
/
user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# User module
class User:
def __init__(self, first, last, hair, eye):
"""Creating a user profile. """
self.first = first
self.last = last
self.hair = hair
self.eye = eye
self.login_attempts = 0
def describe_user(self):
"""Describe user. """
print(f"This is {self.first}. \n")
print(f"{self.first.title()} has {self.hair} hair. \n")
print(f"{self.first} {self.last}. \n")
print(f"{self.first} has {self.eye} eye color. \n")
def greet_user(self):
"""Greet user. """
print(f"HI! {self.first} {self.last} who has {self.hair} hair and {self.eye} eyes. \n")
def increment_login_attempts(self):
"""Increment login attempmts. """
self.login_attempts += 1
print(f"{self.login_attempts}")
def reset_login_attempts(self):
"""Resetting login attempts. """
self.login_attempts = 0
print(f"{self.login_attempts}")
class Admin(User):
"""Attempt to show the permissions of the user. """
def __init__(self, first, last, hair, eye):
"""
Initializing attributes of parent class.
Then adding new attributes that shows permissions.
"""
super().__init__(first, last, hair, eye)
def show_permissions(self, item_1, item_2, item_3):
"""Attempt to show permissions of user"""
self.item_1 = item_1
self.item_2 = item_2
self.item_3 = item_3
print(f"{self.first} can {item_1}, {item_2}, {item_3} all of these records.")
class Privileges(User):
"""
Attempt to write another class.
"""
def __init__(self, first, last, hair, eye):
"""
Initializing attributes from the parent class Admin.
"""
super().__init__(first, last, hair, eye)
self.priv_1 = 3
def show_privileges(self):
"""Show the number of privileges a user has. """
print(f"This user has {self.priv_1}.")