diff --git a/solutions/object_oriented_design/online_chat/online_chat.py b/solutions/object_oriented_design/online_chat/online_chat.py index 7063ca04..ae469484 100644 --- a/solutions/object_oriented_design/online_chat/online_chat.py +++ b/solutions/object_oriented_design/online_chat/online_chat.py @@ -8,7 +8,13 @@ class UserService(object): self.users_by_id = {} # key: user id, value: User def add_user(self, user_id, name, pass_hash): - pass + if user_id not in self.users_by_id: + new_user = User(user_id, name, pass_hash) + self.users_by_id[user_id] = new_user + return new_user + else: + # User with this ID already exists + return None def remove_user(self, user_id): pass