-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.cpp
More file actions
61 lines (53 loc) · 983 Bytes
/
Copy pathUser.cpp
File metadata and controls
61 lines (53 loc) · 983 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "User.h"
// Initializes a new user object
void User::init(unsigned int id, std::string username, unsigned int age)
{
this->id = id;
this->username = username;
this->age = age;
devices.init();
}
// Clears the user object and the associated device list
void User::clear()
{
devices.clear();
id = 0;
username.clear();
age = 0;
}
// Getters
unsigned int User::getID() const
{
return id;
}
std::string User::getUserName() const
{
return username;
}
unsigned int User::getAge() const
{
return age;
}
DevicesList &User::getDevices()
{
return devices;
}
// Adds a device to the user's list of devices
void User::addDevice(Device newDevice)
{
devices.add(newDevice);
}
// Checks if all devices are on
bool User::checkIfDevicesAreOn() const
{
DeviceNode *current = devices.get_first();
while (current != nullptr)
{
if (!current->get_data().isActive())
{
return false;
}
current = current->get_next();
}
return true;
}