-
Notifications
You must be signed in to change notification settings - Fork 0
/
FansPage.h
126 lines (98 loc) · 2.09 KB
/
FansPage.h
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
#pragma once
#include "Status.h"
#include "Friend.h"
#include <vector>
#include <map>
#include "Exeption1.h"
class Friend;
class FansPage {
string name;
vector < Status*> vectorOfStatus;
int numOfStatus = 0;
int statusLogicalSize = 1;
map<const string, Friend*> mapOfFriends;
int numOfFriends = 0;
vector<string>needTodeDelete;//the names we need to delete. this is for diitractor
friend class Control;
friend class Friend;
public:
//constractor
FansPage( string name1)
{
name = name1;
}
//distractor
~FansPage() = default;
//add functions
void addStatus(const string& str);
void addFriend(const string& name, Friend* friend1)noexcept(false)
{
if (mapOfFriends.find(name) != mapOfFriends.end())
{
eror3 ex( name, this->name);
throw ex;
}
numOfFriends++;
mapOfFriends.insert({ name, friend1 });
}
//remove functions
void removeFriend(const string& name)
{
if (mapOfFriends.find(name) != mapOfFriends.end())
{
eror1 ex( name);
throw ex;
}
mapOfFriends.erase(name);
numOfFriends--;
}
//printFunctions
void print()
{
cout << name;
};
void printAllStatus() const ;
void printAllFriends() const ;
void printAllFriendWithIndex() const;//for function 9;
//get fucntions
const string& getName() const
{
return name;
}
int getNumOfFriends() const
{
return numOfFriends;
}
//small functions
void getFriendsName(string& name);
int getNumOfFriends()
{
return numOfFriends;
}
//operators
bool operator>(const Friend& fr);
bool operator>(const FansPage& fansPage)
{
return this->numOfFriends >= fansPage.numOfFriends;
};
bool operator==(const FansPage& fan)
{
return this->name == fan.name;
}
bool operator!=(const FansPage& fan)
{
return !(this->name == fan.name);
}
FansPage& operator+=(const Friend& fr);
FansPage& operator=(const FansPage& fan)
{
name = fan.name;
vectorOfStatus = fan.vectorOfStatus;
numOfStatus = fan.numOfStatus;
statusLogicalSize = fan.statusLogicalSize;
numOfFriends = fan.numOfFriends;
mapOfFriends = fan.mapOfFriends;
return *this;
}
bool hasName(string name);
};