-
Notifications
You must be signed in to change notification settings - Fork 0
/
room.py
44 lines (33 loc) · 988 Bytes
/
room.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
"""
The Room class that holds a list of users that are in the room.
"""
import user
class Room:
def __init__(self, room_name):
self.name = room_name
# list of user nick names, not full user objects
self.list_of_users = []
def get_name(self):
return self.name
def add_user(self, new_user):
if new_user in self.list_of_users:
return False
self.list_of_users.append(new_user)
return True
def delete_user(self, user):
if user in self.list_of_users:
self.list_of_users.remove(user)
return True
return False
def list_users(self):
for user in self.list_of_users:
print(user)
def get_list_of_users(self):
return self.list_of_users
def main():
test_room = Room("test_room")
user1 = user.User("test_real_name", "test_nick")
test_room.add_user(user1)
test_room.list_users()
if __name__ == "__main__":
main()