-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.cpp
More file actions
79 lines (63 loc) · 1007 Bytes
/
user.cpp
File metadata and controls
79 lines (63 loc) · 1007 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include "user.h"
#include "menu.h"
#include <cstring>
#include "plotter.h"
#include <fstream>
#include <cstdlib>
using namespace std;
User::User()
{
User("guest");
}
User::User(string n)
{
name=n;
ifstream file;
file.open(("users\\"+name+".usr").c_str());
getline(file,pwd);
getline(file,hint);
file>>score;
file.close();
}
User::~User()
{
ofstream file;
file.open(("users\\"+name+".usr").c_str());
file<<pwd << endl;
file<<hint<<endl;
file<<score<<endl;
file.close();
}
string User::getName()
{
return name;
}
bool User::checkPass(string s)
{
return pwd.compare(s) == 0;
}
bool User::changePass(string oldP,string newP)
{
bool ret=false;
if(checkPass(oldP))
{
pwd=newP;
ret=true;
}
return ret;
}
int User::getScore()
{
return score;
}
bool User::setScore(int i)
{
bool ret=false;
if(i>score)
{
score=i;
ret=true;
}
return ret;
}