-
Notifications
You must be signed in to change notification settings - Fork 0
/
Message.cpp
71 lines (57 loc) · 1.14 KB
/
Message.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
#include "Message.h"
#include <iostream>
#include "User.h"
#include "Date.h"
#include "Utilities.h"
#include <string>
#include <vector>
using namespace std;
Message::Message(string m, User *u){
text=m;
timestamp.updateTime();
user = u;
}
int Message::getLikes(){
return likes.size();
}
void Message::addLike(User *u){
int i = Utilities::findPositionVector(likes, u);
if(i==-1){
likes.push_back(u);
}
else{
cout<<"You have already liked this message"<<endl;
system("PAUSE");
}
}
void Message::removeLike(User *u){
int i = Utilities::findPositionVector(likes, u);
if(i!=-1){
likes.erase(likes.begin()+i-1);
}
else{
cout<<"User hasn't liked this message!"<<endl;
system("PAUSE");
}
}
Date Message::getTimestamp(){
return timestamp;
}
string Message::getText(){
return text;
}
vector<Message*> Message::getReplies(){
return replies;
}
void Message::addReply(Message *m){
replies.push_back(m);
}
User* Message::getUser(){
return user;
}
vector<User*> Message::getLikeArray(){
return likes;
}
void Message::setTimestamp(string t){
timestamp.setTime(t);
}