-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleNote.cpp
More file actions
41 lines (35 loc) · 1.12 KB
/
SimpleNote.cpp
File metadata and controls
41 lines (35 loc) · 1.12 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
#include "SimpleNote.hpp"
#include <iostream>
#include <fstream>
#include "Utils.h"
#include <filesystem>
using namespace std;
void SimpleNote::create() {
cout << "----------------------------------------------\n";
cout << "Enter title: ";
getline(cin, title);
cout << "Enter note body:\n";
getline(cin, body);
}
void SimpleNote::display() const {
cout << "----------------------------------------------\n";
cout << "Title:"; Utils::printYellow(title + "\n");
cout << "Body: \n"; Utils::printYellow(body + "\n");
}
void SimpleNote::saveToFile(const string& userFolder, const string& filename) const {
// Save the note to a file in the specified user folder
ofstream file(userFolder + "/" + filename);
file << "SimpleNote\n" << title << "\n" << body << "\n";
}
void SimpleNote::loadFromFile(ifstream& in) {
getline(in, title);
string line, bodyContent;
while (getline(in, line)) {
bodyContent += line + "\n";
}
body = bodyContent;
}
string SimpleNote::getType() const {
// Return the type of the note
return "SimpleNote";
}