-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.cpp
82 lines (69 loc) · 1.21 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
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
#include "User.h"
User::User()
{
this->name = "";
this->password = "";
this->isAdmin = 0;
this->isLoggedIn = 0;
}
User::User(String& _name, String& _pass)
{
this->name = _name;
this->password = _pass;
this->isAdmin = 1;
this->isLoggedIn = 1;
}
const String& User::getName() const
{
return this->name;
}
void User::setName(const String& _name)
{
this->name = _name;
}
const String& User::getPassword() const
{
return this->password;
}
void User::setPassword(const String& _password)
{
this->password = _password;
}
const bool User::getAdmin() const
{
return this->isAdmin;
}
const bool User::getLoggedIn() const
{
return this->isLoggedIn;
}
void User::setLoggedIn(const bool _status)
{
this->isLoggedIn = _status;
}
void User::setAdmin(const bool _level)
{
this->isAdmin = _level;
}
void User::loadUser(std::ifstream& in)
{
in >> name;
if (name == "\n")
in >> name;
in >> password;
in >> isAdmin;
in >> isLoggedIn;
}
void User::saveUser(std::ostream& out) const
{
out << name << "\n";
out << password << "\n";
out << isAdmin << "\n";
out << isLoggedIn << "\n";
}
bool User::operator==(const User& user)
{
if (this->name == user.name && this->password == user.password)
return true;
return false;
}