-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (38 loc) ยท 1.33 KB
/
main.py
File metadata and controls
44 lines (38 loc) ยท 1.33 KB
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
from api import fetch_articles
from queue_articles import ArticleQueue
from stack_history import ArticleStack
def menu():
queue = ArticleQueue()
stack = ArticleStack()
print("๐ Chargement des articles...")
articles = fetch_articles()
for article in articles:
queue.enqueue(article)
while True:
print("\n===== MENU =====")
print("1. ๐ Lire un article")
print("2. ๐ Voir le dernier article lu")
print("q. ๐ช Quitter")
choix = input("Entrez votre choix (1-3): ")
if choix == '1':
if queue.is_empty():
print("โ
Tous les articles ont รฉtรฉ lus !")
else:
article = queue.dequeue()
stack.push(article)
print(f"\n๐น {article[0]}")
print(f"๐ {article[1]}")
elif choix == '2':
if stack.is_empty():
print("โ Aucun article lu pour le moment.")
else:
last_read = stack.pop()
print(f"\n๐ Dernier article lu : {last_read[0]}")
print(f"๐ {last_read[1]}")
elif choix == 'q':
print("๐ Au revoir !")
break
else:
print("โ Entrรฉe invalide. Choisissez entre 1, 2 ou 3.")
if __name__ == "__main__":
menu()