-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.cpp
More file actions
63 lines (56 loc) · 1.35 KB
/
project.cpp
File metadata and controls
63 lines (56 loc) · 1.35 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
#include "project.hpp"
#include <iostream>
#include <ctime>
#include <string>
project::~project(){
for (size_t i = 0; i < items.size(); i++) {
delete items.at(i);
}
}
void project::add_item(Base* b){
items.push_back(b);
}
void project::add_task(){
task *newTask = new task();
items.push_back(newTask);
}
void project::add_task(string nm, string d, int p) {
task *newTask = new task(d, p);
newTask->setName(nm);
items.push_back(newTask);
}
void project::add_Project(project *proj) {
project *newProj = proj;
items.push_back(newProj);
}
void project::print_project(){
if (items.empty()){
std::cout << "Project \""<<this -> getName()<<"\" has no projects."<<std::endl;
}
else{
for(size_t i=0; i<items.size(); i++){
std::cout<< i+1<<". "<<items.at(i)->getName()<<": "<< items.at(i)->getDescription()<<std::endl;
}
}
}
Base * project::search(string nm) {
Base *proj = nullptr;
bool found;
for (size_t i = 0; i < items.size(); i++) {
if (items.at(i)->getName() == nm) {
proj = items.at(i);
found = true;
}
}
if (!found){
std::cout <<'\"' << this->getName() << "\" has no project titled \"" << nm << '\"' << std::endl;
return nullptr;
}
return proj;
}
vector<Base*> project::get_items() {
return items;
}
bool project::has_elements() {
return !items.empty();
}