-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.py
55 lines (45 loc) · 1.7 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
class User:
"""
initializes a new User class
"""
user_list=[] #****************our list where we shall store our users****************
def __init__(self, firstname, lastname, username, passcode):
"""
the method here for defining properties of the object
"""
self.firstname = firstname
self.lastname = lastname
self.username = username
self.passcode = passcode
#*************************saving new user*****************************************
def save_User(self):
"""
save_User append the new user to our list
"""
User.user_list.append(self)
#********************deleting or removing our new user**************************
def delete_user(self):
"""
removing user form the list
"""
User.user_list.remove(self)
#*******searching for a user using the unique password*****************************
@classmethod
def find_by_passcode(cls, passcode): #cls takes the whole class
for User in cls.user_list:
if User.passcode == passcode:
return User
#*************************check to see if the user really exists*******************
@classmethod
def user_exist(cls,passcode):
for User in cls.user_list:
if User.passcode == passcode:
return True
return False
#***************************display users*************************************************
@classmethod
def display_users(cls):
'''
see our users in our userlist by returning the user list
'''
return cls.user_list