-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFaceBook.cpp
58 lines (51 loc) · 1.14 KB
/
FaceBook.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
#include"FaceBook.h"
FaceBook::FaceBook()
{}
FaceBook::~FaceBook()
{
for (int i = 0; i < (int)users.size(); i++)
delete this->users[i];
}
void FaceBook::addUser(User* new_user)
{
this->users.push_back(new_user);
if (typeid(*new_user) == typeid(Member))
this->number_of_members += 1;
else
this->number_of_pages += 1;
}
int FaceBook:: getNumberOfUsers()const
{
return (int)this->users.size();
}
vector<User*> FaceBook::getAllUsers() const
{
return this->users;
}
void FaceBook::show() const
{
cout << endl << "\t\t******PAGES******" << endl;
if (this->number_of_pages)
{
int index = 1;
for (int i = 0; i < (int)this->users.size(); i++)
{
if (typeid(*users[i]) == typeid(Page))
cout << "\t\t(" << index++ << ")" << this->users[i]->getName() << endl;
}
}
else
cout << "\t\tNo Pages In FaceBook" << endl;
cout << "\t\t*****MEMBERS*****" << endl;
if (this->number_of_members)
{
int index = 1;
for (int i = 0; i < (int)this->users.size(); i++)
{
if (typeid(*users[i]) == typeid(Member))
cout << "\t\t(" << index++ << ")" << this->users[i]->getName() << endl;
}
}
else
cout << "\t\tNo Members In FaceBook" << endl;
}