-
Notifications
You must be signed in to change notification settings - Fork 0
/
Human.cpp
84 lines (73 loc) · 1.49 KB
/
Human.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
84
#include "human.h"
#include <iostream>
#include <fstream>
Human::Human(std::string _fileName)
{
fileName = _fileName;
//init(fileName);
}
int Human::getId()
{
return id;
}
int Human::getBla()
{
return bla;
}
void Human::recharge(double ch)
{
bla += ch;
}
std::string Human::getTel()
{
return tel;
}
std::string Human::getName()
{
return name;
}
/*std::istream& operator >> (std::istream& in, Human& A)
{
in >> A.id >> A.bla >> A.name >> A.tel >> A.passwd;
return in;
}
std::ostream& operator << (std::ostream& out, Human& A)
{
out << A.id << '\n';
out << A.bla << '\n';
out << A.name << '\n';
out << A.tel << '\n';
out << A.passwd << '\n';
return out;
}*/
int Human::checkPasswd(const std::string newPasswd)
{
if (newPasswd.length() == 0)
return EMPTY_PASSWD;
if (passwd == newPasswd)
return EQUAL_TO_OLD_PASSWD;
return VALID_NEW_PASSWD;
}
int Human::modifyPasswd(const std::string newPasswd)
{
int response = checkPasswd(newPasswd);
switch (response)
{
case VALID_NEW_PASSWD:
passwd = newPasswd;
std::cout << "Your password has been sucessfully updated!\n";
break;
case EMPTY_PASSWD:
std::cout << "Password can not be empty! Failed.\n";
break;
case EQUAL_TO_OLD_PASSWD:
std::cout << "Password are equal to the old one! Failed.\n";
break;
}
return response;
}
int Human::modifyFileName(std::string file)
{
fileName = file;
return 0;
}