-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.py
32 lines (25 loc) · 937 Bytes
/
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
class UserManager:
def __init__(self):
self.user_list = []
self.counter = 0
def generate_id(self):
self.counter += 1
return self.counter
def create_a_user(self, name, password, type):
new_user_id = self.generate_id()
new_user = User(new_user_id, name, password, type)
self.user_list.append(new_user)
def find_users(self, ids):
users_found = []
for user in self.user_list:
if user.user_id in ids:
users_found.append(user)
return users_found
class User():
def __init__(self, user_id: int, name: str, password: str, type: str):
self.user_id = user_id
self.name = name
self.password = password
self.type = type # type should be either student/teacher/admin
def __str__(self):
return f"ID: {self.user_id}, name: {self.name}, type: {self.type}"