222.2 Class design / TaskManager
This section outlines the design of the TaskManager class, which is responsible for storing and managing multiple Task objects.
Last updated
Was this helpful?
This section outlines the design of the TaskManager class, which is responsible for storing and managing multiple Task objects.
Last updated
Was this helpful?
Was this helpful?
class TaskManager:
def __init__(self):
self.tasks = []
def add_task(self, task):
self.tasks.append(task)
def list_tasks(self):
for task in self.tasks:
task.display_summary()
def find_task(self, title):
for task in self.tasks:
if task.title == title:
return task
return None
def remove_task(self, title):
task = self.find_task(title)
if task:
self.tasks.remove(task)
def get_completed_tasks(self):
return [task for task in self.tasks if task.is_complete]
def get_incomplete_tasks(self):
return [task for task in self.tasks if not task.is_complete]
def display_all_tasks(self):
for task in self.tasks:
task.display_details()