-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14.py
More file actions
44 lines (31 loc) · 987 Bytes
/
14.py
File metadata and controls
44 lines (31 loc) · 987 Bytes
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
class Task:
def __init__(self, title, completed=False):
self.title = title
self.completed = completed
def info(self):
if self.completed:
print(f"Task: {self.title} | Done")
else:
print(f"Task: {self.title} | Pending")
class TaskManager:
def __init__(self):
self.tasks = []
def add_task(self, task):
self.tasks.append(task)
print(f"Task added: {task.title}")
def show_tasks(self):
for task in self.tasks:
task.info()
def complete_task(self, title):
for task in self.tasks:
if task.title == title:
task.completed = True
print(f"Task completed: {task.title}")
t1 = Task("Study Python")
t2 = Task("Do Homework")
manager = TaskManager()
manager.add_task(t1)
manager.add_task(t2)
manager.show_tasks()
manager.complete_task("Study Python")
manager.show_tasks()