diff --git a/src/project.cpp b/src/project.cpp index 59ccbb0..4495abb 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -19,3 +19,15 @@ void Project::remove_task(int id){ Project::active_task = std::max(id-1,0); Project::num_tasks--; } + +void ProjectList::add_project(Project proj){ + ProjectList::projects.push_back(proj); + ProjectList::active_project = ProjectList::num_projects; + ProjectList::num_projects++; +} + +void ProjectList::remove_project(int id){ + ProjectList::projects.erase(projects.begin()+id); + ProjectList::active_project = std::max(id-1,0); + ProjectList::num_projects--; +} diff --git a/src/project.h b/src/project.h index 4711846..04bcb8f 100644 --- a/src/project.h +++ b/src/project.h @@ -16,5 +16,13 @@ class Project{ int active_task; }; +class ProjectList{ + public: + int num_projects; + std::vector projects; + void add_project(Project proj); + void remove_project(int id); + int active_project; +}; #endif diff --git a/src/tt.cpp b/src/tt.cpp index 3f312f3..5eff5d5 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -1,4 +1,5 @@ #include +#include #include "task.h" #include "project.h" @@ -15,5 +16,12 @@ int main(){ std::cout << "Removing Task 0 from Project" << std::endl; proj.remove_task(0); std::cout << "Number of tasks in project: " << proj.num_tasks << std::endl; + + ProjectList proj_list; + proj_list.add_project(proj); + std::cout << "Project List no of projects: " << proj_list.num_projects << " Name of active proj: " << proj_list.projects[proj_list.active_project].name << std::endl; + + proj_list.remove_project(0); + std::cout << "Project List no of projects: " << proj_list.num_projects << std::endl; return 0; }