-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
42 lines (34 loc) · 1.04 KB
/
Copy pathtasks.py
File metadata and controls
42 lines (34 loc) · 1.04 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
from id_generator import generate_unique_id
class Task:
"""
A class representing a task with a unique ID, title, completion status,
due date, and tags.
"""
def __init__(self, title, due_date=None):
self.id = generate_unique_id()
self.title = title
self.completed = False
self.due_date = due_date
self.tags = []
def mark_complete(self):
self.completed = True
return self
def create_task(title, due_date=None):
"""
Create a new task with a unique ID and optional due date.
"""
return Task(title, due_date)
def display_task(task):
"""
Display the task details in a multiline format.
"""
status = "Completed" if task.completed else "Not Completed"
due_date = task.due_date if task.due_date else "No due date"
tags = ", ".join(task.tags) if task.tags else "No tags"
return (
f"Task ID: {task.id}\n"
f"Title: {task.title}\n"
f"Status: {status}\n"
f"Due Date: {due_date}\n"
f"Tags: {tags}"
)