-
Notifications
You must be signed in to change notification settings - Fork 0
/
FansPage.cpp
96 lines (78 loc) · 1.62 KB
/
FansPage.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "FansPage.h"
//add functions
void FansPage::addStatus(const string& str)
{
Status* newStatus = new Status(str);
numOfStatus++;
if (numOfStatus == statusLogicalSize)
{
statusLogicalSize *= 2;
vectorOfStatus.resize(statusLogicalSize);
vectorOfStatus[numOfStatus - 1] =newStatus;
}
else
{
vectorOfStatus[numOfStatus - 1] =newStatus;
}
}
//print fanctions
void FansPage::printAllStatus() const
{
int i;
if (numOfStatus == 0)
cout << "their are no status for this fans page\n";
for (i = 0; i < numOfStatus; i++)
{
vectorOfStatus[i]->printStatus();
cout << "\n";
}
}
void FansPage::printAllFriends()const
{
if (numOfFriends == 0)
{
cout << "their are no friends for this fans page\n";
return;
}
auto it = mapOfFriends.begin();
for (it; it != mapOfFriends.end(); it++)
cout << it->first;
}
//small functions
void FansPage::getFriendsName(string& name1)
{
if (numOfFriends == 0)
{
eror9 ex( name, this->name);
throw ex;
}
cout << "please enter a friend's name who is friend of: " << name << "\n";
cin >> name;
if (mapOfFriends.find(name1) == mapOfFriends.end())
{
eror9 ex( name, this->name);
throw ex;
}
}
//operator
FansPage& FansPage:: operator+=(const Friend & fr)
{
Friend* newFriendPtr = new Friend(fr.name);
*newFriendPtr = fr;
needTodeDelete.push_back(fr.name);
this->addFriend(fr.name, newFriendPtr);
return *this;
}
bool FansPage::operator>(const Friend& fr)
{
return this->numOfFriends >= fr.numOfFriends;
}
bool FansPage::hasName(string name)
{
for (int i = 0; i < needTodeDelete.size(); i++)
{
if (needTodeDelete[i] == name)
return true;
}
return false;
}