-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote.cpp
More file actions
50 lines (42 loc) · 1.14 KB
/
note.cpp
File metadata and controls
50 lines (42 loc) · 1.14 KB
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
#include "note.h"
Note::Note(string fileName) {
ifstream in(fileName);
if(in.is_open()) {
in >> name >> text >> date >> textCheckSum >> nameCheckSum;
} else {
cerr << "Note file not found: " << fileName << endl;
}
}
void Note::setText(string text) {
this->text = text;
}
void Note::init(string name, string text, string date, uint32_t textCheckSum, uint32_t nameCheckSum) {
this->name = name;
this->text = text;
this->date = date;
this->textCheckSum = textCheckSum;
this->nameCheckSum = nameCheckSum;
}
string Note::getName(string password) const {
if(isValid(name, password)) {
return decode(name, password);
} else {
return to_string(nameCheckSum);
}
}
string Note::getText(string password) const {
if(isValid(text, password)) {
return decode(text, password);
} else {
return to_string(textCheckSum);
}
}
string Note::getDate() const {
return date;
}
bool Note::isValid(string text, string password) const {
return text.size() + password.size(); // !!!
}
string Note::decode(string text, string password) const {
return text; //!!!
}