From 307c3ff41433701c19e03136a4916b5b87e40c10 Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sat, 23 Nov 2024 18:31:53 +0100 Subject: [PATCH] chore(): Expands the definitions of the entities - Adds create methods to the room, person and cards - Adds methods to add and remove person from room --- src/entities/cards.py | 21 +++++++++++++++++++++ src/entities/person.py | 11 +++++++++++ src/entities/room.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/entities/cards.py b/src/entities/cards.py index abf164a..7e95e39 100644 --- a/src/entities/cards.py +++ b/src/entities/cards.py @@ -2,3 +2,24 @@ CARDS = { "fibonacci": [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, "?"], "tshirt": ["XS", "S", "M", "L", "XL", "XXL", "XXXL", "?"], } + + +class Cards: + """ + Cards class object + """ + + def __init__(self, card_type="fibonacci"): + self.card_type = card_type + self.cards = [] + self.create() + + def create(self): + """ + Method to create a deck of cards + """ + if self.card_type in CARDS.keys(): + self.cards = CARDS[self.card_type] + return self + + return None diff --git a/src/entities/person.py b/src/entities/person.py index bbd4e20..5a5ebd3 100644 --- a/src/entities/person.py +++ b/src/entities/person.py @@ -1,3 +1,6 @@ +import uuid + + class Person: """ Person entity @@ -8,3 +11,11 @@ class Person: Person entity initializer """ self.name = name + self.uuid = None + self.create() + + def create(self): + if not self.uuid: + self.uuid = uuid.uuid1() + + return self diff --git a/src/entities/room.py b/src/entities/room.py index e694bbc..e24edb2 100644 --- a/src/entities/room.py +++ b/src/entities/room.py @@ -1,3 +1,6 @@ +import uuid + + class Room: """ Room entity @@ -8,3 +11,29 @@ class Room: Room entity initializer """ self.name = name + self.uuid = None + self.attendant = [] + self.create() + + def create(self): + """ + Method to create a new room object + """ + if not self.uuid: + self.uuid = uuid.uuid1() + + return self + + def add_person(self, person: uuid.UUID): + """ + Method to add a person to a room + """ + if person not in self.attendant: + self.attendant.append(person) + + def remove_person(self, person: uuid.UUID): + """ + Method to remove a person from a room + """ + if person in self.attendant: + self.attendant.remove(person)