School Commit Init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include "repo.h"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
Repo::Repo()
|
||||
{
|
||||
this->readFromFile();
|
||||
}
|
||||
|
||||
Repo::~Repo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Repo::addTask(Task task)
|
||||
{
|
||||
this->tasks.push_back(task);
|
||||
}
|
||||
|
||||
std::vector<Task> Repo::getTasks()
|
||||
{
|
||||
return this->tasks;
|
||||
}
|
||||
|
||||
void Repo::readFromFile()
|
||||
{
|
||||
std::ifstream file("tasks.txt");
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
std::string description = line.substr(0, line.find("|"));
|
||||
line.erase(0, line.find("|") + 1);
|
||||
int duration = std::stoi(line.substr(0, line.find("|")));
|
||||
line.erase(0, line.find("|") + 1);
|
||||
std::string date = line.substr(0, line.find("|"));
|
||||
Task task(description, duration, date);
|
||||
this->addTask(task);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user