-
Notifications
You must be signed in to change notification settings - Fork 7
/
Task.cpp
83 lines (70 loc) · 1.84 KB
/
Task.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "Task.h"
// Constructor
Task::Task(int priority, TaskType type, const string &desc)
: m_description(desc), m_priority(priority), m_type(type)
{
// enforce priority range of 0-100
// 0 is lowest priority, 100 is highest
if (m_priority < 0)
{
m_priority = 0;
}
else if (m_priority > 100)
{
m_priority = 100;
}
}
Task::Task(int priority, const string &desc)
: Task(priority, TaskType::General, desc) {}
// Getters and setters
int Task::getId() const {
return m_id;
}
void Task::setId(int newId) {
m_id = newId;
}
TaskType Task::getType() const {
return m_type;
}
string Task::getDescription() const {
return m_description;
}
int Task::getPriority() const {
return m_priority;
}
// Overloaded operators
ostream &operator<<(ostream& os, const Task& task) {
os << "Task ID: " << task.m_id << ", Priority: " << task.m_priority;
os << ", Type: " << taskTypeToString(task.m_type) << ", Description: " << task.m_description;
return os;
}
bool operator>(const Task& lhs, const Task& rhs) {
return lhs.m_priority > rhs.m_priority;
}
// Convert TaskType to string
std::string taskTypeToString(TaskType type) {
switch (type) {
case TaskType::Meeting:
return "Meeting";
case TaskType::Presentation:
return "Presentation";
case TaskType::Documentation:
return "Documentation";
case TaskType::Development:
return "Development";
case TaskType::Testing:
return "Testing";
case TaskType::Research:
return "Research";
case TaskType::Training:
return "Training";
case TaskType::Maintenance:
return "Maintenance";
case TaskType::CustomerSupport:
return "Customer Support";
case TaskType::General:
return "General";
default:
return "Unknown Task";
}
}