State pour l'agent
This commit is contained in:
40
AgentReact/utils/StateElements/TodoElement.py
Normal file
40
AgentReact/utils/StateElements/TodoElement.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# Classes utilisées pour représenter des données
|
||||
class TodoElement():
|
||||
STATE_NOT_STARTED = 0 # Sorte d'enum qui représente l'état d'une tâche
|
||||
STATE_STARTED = 1
|
||||
STATE_COMPLETED = 2
|
||||
|
||||
name: str
|
||||
state: int
|
||||
|
||||
def __init__(self, name:str, description:str=None):
|
||||
self.name = name
|
||||
self.description = description
|
||||
self.state = TodoElement.STATE_NOT_STARTED
|
||||
|
||||
def __str__(self)->str:
|
||||
"""
|
||||
Affiche la tâche, son nom et son statut
|
||||
Affichera aussi la description de la tâche si elle a été définie ET est en cours
|
||||
|
||||
Returns:
|
||||
str: Représentation écrite de la tâche
|
||||
"""
|
||||
return f"Tâche \"{self.name}\": {self.__getStateName()}." + \
|
||||
(f" Description: {self.description}" if self.description and self.state == TodoElement.STATE_STARTED else '')
|
||||
|
||||
def __getStateName(self)->str:
|
||||
if self.state == TodoElement.STATE_NOT_STARTED:
|
||||
return "Non commencée"
|
||||
elif self.state == TodoElement.STATE_STARTED:
|
||||
return "En cours"
|
||||
elif self.state == TodoElement.STATE_COMPLETED:
|
||||
return "Terminée"
|
||||
else:
|
||||
return "Inconnu"
|
||||
|
||||
if __name__ == "__main__":
|
||||
test = TodoElement("TEST tâche", "OUI")
|
||||
test.state = TodoElement.STATE_STARTED
|
||||
print(test)
|
||||
print([str(test)])
|
||||
Reference in New Issue
Block a user