-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPinNote.cpp
More file actions
64 lines (55 loc) · 1.65 KB
/
Copy pathPinNote.cpp
File metadata and controls
64 lines (55 loc) · 1.65 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "PinNote.hpp"
#include <iostream>
#include <fstream>
#include "Utils.h"
using namespace std;
void PinNote::create() {
cout << "----------------------------------------------\n";
cout << "Enter main work topic (title): ";
getline(cin, title);
cout << "Enter pin keywords (type 'done' to finish):\n";
string word;
getline(cin, word);
if (word == "done"){
keywords.push_back(word);
}
while (word != "done") {
if (!word.empty()) {
keywords.push_back(word);
}
getline(cin, word);
}
if (keywords.empty()) {
cout << "----------------------------------------------\n";
Utils::printRed("No keywords entered. PinNote creation failed.");
return;
}
}
void PinNote::display() const {
cout << "Pinned: " << title;
Utils::printBlue("\n\nDeduction chain: ");
for (size_t i = 0; i < keywords.size(); ++i) {
cout << keywords[i];
if (i != keywords.size() - 1) cout << " :---: ";
}
cout << "\n";
}
void PinNote::saveToFile(const string& userFolder, const string& filename) const {
ofstream file(userFolder + "/" + filename);
file << "PinNote\n" << title << "\n";
for (const auto& w : keywords) {
file << w << "\n";
}
}
void PinNote::loadFromFile(ifstream& in) {
getline(in, title); // First actual data line after "PinNote"
string line;
keywords.clear(); // Just in case
while (getline(in, line)) {
if (!line.empty())
keywords.push_back(line);
}
}
string PinNote::getType() const {
return "PinNote";
}