-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathUser.cpp
36 lines (30 loc) · 1.26 KB
/
User.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
#include "User.hpp"
#include <iostream>
#include <algorithm>
User::User(std::string userId, std::string username, std::string email)
: userId(userId), username(username), email(email), active(true) {}
std::string User::getUserId() const { return userId; }
std::string User::getUsername() const { return username; }
std::string User::getEmail() const { return email; }
const std::vector<std::string>& User::getAssignedTasks() const { return assignedTasks; }
bool User::isActive() const { return active; }
void User::addTask(const std::string& taskId) {
if (std::find(assignedTasks.begin(), assignedTasks.end(), taskId) == assignedTasks.end()) {
assignedTasks.push_back(taskId);
}
}
void User::removeTask(const std::string& taskId) {
auto it = std::find(assignedTasks.begin(), assignedTasks.end(), taskId);
if (it != assignedTasks.end()) {
assignedTasks.erase(it);
}
}
void User::setActive(bool status) {
active = status;
}
void User::displayInfo() const {
std::cout << "User: " << username << " (ID: " << userId << ")" << std::endl;
std::cout << "Email: " << email << std::endl;
std::cout << "Status: " << (active ? "Active" : "Inactive") << std::endl;
std::cout << "Assigned Tasks: " << assignedTasks.size() << std::endl;
}