-
Notifications
You must be signed in to change notification settings - Fork 0
/
Friend.cpp
128 lines (102 loc) · 2.12 KB
/
Friend.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "Friend.h"
//add functions
//get reference for avoid get NULL status
void Friend::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;
}
}
//need to look one time again for this function---need to fix
// |
// |
// |
// \ /
// V
//remove functions
//print functions
void Friend::print10Status() const
{
int i;
for (i = 1; i <= 10; i++)
{
if ((numOfStatus - i) < 0)
break;
vectorOfStatus[numOfStatus - i]->printStatus();
cout << "\n";
}
}
void Friend::print10StatusOfEachFriend() const
{
if (numOfFriends == 0) {
cout << name << "have no friend \n";
return;
}
auto it = mapOfFriends.begin();
for (it; it != mapOfFriends.end(); it++)
it->second->print10Status();
}
void Friend::printAllFriends() const
{
auto it = mapOfFriends.begin();
for (it; it != mapOfFriends.end(); it++)
cout << it->first<<"\n";
}
void Friend::printAllStatus() const
{
int i;
if (numOfStatus==0)
cout << "their are no status for this friend\n";
for (i = 0; i < numOfStatus; i++)
{
vectorOfStatus[i]->printStatus();
cout << "\n";
}
}
//small functions
void Friend::getFriendsName(string& name1)
{
if (numOfFriends == 0)
{
eror4 ex( name);
throw ex;
}
cout << "please enter a friend's name who is friend of: "<<name<<"\n";
cin >> name;
if (mapOfFriends.find(name1) == mapOfFriends.end())
throw name1;
}
void Friend::getFansPageName(string& name1)
{
if (numOfFanPage == 0)
{
eror7 ex(name);
throw ex;
}
cout << "please enter a fansPage's name who is friend of: " << name << "\n";
cin >> name;
if (mapOfFansPage.find(name1) == mapOfFansPage.end())
throw name1;
}
bool Friend:: operator>(const FansPage& fansPage)
{
return this->numOfFriends >= (fansPage.getNumOfFriends());
}
bool Friend::hasName(string name)
{
for (int i = 0; i < needTodeDelete.size(); i++)
{
if (needTodeDelete[i] == name)
return true;
}
return false;
}