forked from thuvu33/design_pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.cpp
More file actions
70 lines (53 loc) · 1.19 KB
/
Copy pathProject.cpp
File metadata and controls
70 lines (53 loc) · 1.19 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
65
66
67
68
#include "Project.h"
#include "ProjectIterator.h"
#include <stdio.h>
#include <iostream>
#include <vector>
using std::string;
using std::vector;
CProject::CProject( void )
{
m_name = "";
m_num = 0;
m_cost = 0;
}
CProject::CProject(string name, int num, int cost)
:m_name(name)
, m_num(num)
, m_cost(cost)
{
}
CProject::~CProject(void)
{
}
string CProject::GetProjectInfo()
{
string info = "";
info.append("项目名称是:");
info.append(this->m_name);
info.append("\t项目人数:");
char tmp[20] = {0};
sprintf(tmp, "%d", m_num);
info.append(tmp);
info.append("\t项目费用:");
sprintf(tmp, "%d", m_cost);
info.append(tmp);
return info;
}
void CProject::Add( string name, int num, int cost )
{
this->m_projectList.push_back(new CProject(name, num, cost));
}
IProjectIterator * CProject::GetIterator()
{
return new CProjectIterator(this->m_projectList);
}
void CProject::Erase()
{
vector<IProject*>::reverse_iterator projectDelIt = m_projectList.rbegin();
for (; projectDelIt != m_projectList.rend(); projectDelIt++) {
delete (*projectDelIt);
(*projectDelIt) = NULL;
}
m_projectList.clear();
}