0% found this document useful (0 votes)
115 views2 pages

Task Manager Functionality Overview

The document defines a Task class to represent tasks with name, description, deadline, priority and status attributes. It also defines a TaskManager class to manage a list of tasks and provide methods to add, remove, update and report on tasks.

Uploaded by

sudharan271
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views2 pages

Task Manager Functionality Overview

The document defines a Task class to represent tasks with name, description, deadline, priority and status attributes. It also defines a TaskManager class to manage a list of tasks and provide methods to add, remove, update and report on tasks.

Uploaded by

sudharan271
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

class Task:

def __init__(self, name, description, deadline, priority):


[Link] = name
[Link] = description
[Link] = deadline
[Link] = priority
[Link] = False

def __str__(self):
status = "Completed" if [Link] else "Incomplete"
return f"Task: {[Link]}\nDescription: {[Link]}\nDeadline:
{[Link]}\nPriority: {[Link]}\nStatus: {status}\n"

class TaskManager:
def __init__(self):
[Link] = []

def add_task(self, task):


[Link](task)

def remove_task(self, task_name):


for task in [Link]:
if [Link] == task_name:
[Link](task)
return
print("Task not found.")

def update_task(self, task_name, updated_description, updated_deadline,


updated_priority, completed=False):
for task in [Link]:
if [Link] == task_name:
[Link] = updated_description
[Link] = updated_deadline
[Link] = updated_priority
[Link] = completed
return
print("Task not found.")

def get_all_tasks(self):
return [Link]

def get_task_by_name(self, name):


for task in [Link]:
if [Link] == name:
return task
return None

def generate_report(self):
completed_tasks = [task for task in [Link] if [Link]]
incomplete_tasks = [task for task in [Link] if not [Link]]

print(f"Completed Tasks ({len(completed_tasks)}):")


for task in completed_tasks:
print(task)

print(f"Incomplete Tasks ({len(incomplete_tasks)}):")


for task in incomplete_tasks:
print(task)
def main():
task_manager = TaskManager()

# Add some tasks to the task manager.


task_manager.add_task(Task("Finish this task manager", "Implement all the
features.", "2023-10-09", 1))
task_manager.add_task(Task("Write a blog post about this task manager",
"Describe the features and benefits of this task manager.", "2023-10-10", 2))

# Update a task.
task_manager.update_task("Finish this task manager", "Implement all the
features and tests.", "2023-10-09", 1, completed=True)

# Remove a task.
task_manager.remove_task("Write a blog post about this task manager")

# Generate a report.
task_manager.generate_report()

if __name__ == "__main__":
main()

You might also like