-
Notifications
You must be signed in to change notification settings - Fork 261
/
02_03e.py
40 lines (31 loc) · 858 Bytes
/
02_03e.py
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
from collections import deque
from threading import Thread
class Task(object):
def __init__(self, taskDesc, hasPriority=False):
self.hasPriority = hasPriority
self.taskDesc = taskDesc
def __str__(self):
return "Task: {0}, Priority: {1} ".format(self.taskDesc,self.hasPriority)
task_queue = deque()
def add_task (task):
if task.hasPriority:
task_queue.appendleft(task)
else:
task_queue.append(task)
def do_task():
return task_queue.popleft()
def print_tasks():
for t in task_queue:
print (t.taskDesc)
def main():
print(task_queue)
add_task(Task("Write List"))
#print_tasks()
add_task(Task("Make Breakfast"))
add_task(Task("Respond to Email", True))
print(task_queue)
print_tasks()
print(do_task())
return
if __name__ == "__main__":
main()