-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMessage.java
More file actions
63 lines (60 loc) · 1.39 KB
/
Message.java
File metadata and controls
63 lines (60 loc) · 1.39 KB
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
import java.util.Date;
public class Message
{
private Date timestamp;
private String text;
private Message nextReply;
private int likes;
private User creator;
private Message fatherMessage;
//Constructor
Message(String creatorName,String words) //The constructor will receive creator Name and the text and will create a post in a wall
{
this.timestamp = new Date();
this.text=words;
this.likes=0;
this.creator=User.getUserFromString(creatorName);
}
// Constructor For Message that have a message as reply
Message(String creatorName,String words,Message e) //This constructor will post message that reply to message e
{
this.timestamp = new Date();
this.text=words;
this.likes=0;
this.creator=User.getUserFromString(creatorName);
this.fatherMessage=e;
}
//Getter and Setter Methods
public String toString()
{
return this.text+ " from "+this.creator+" that created at "+this.getDateAsString();
}
int getLikes()
{
return this.likes;
}
String getDateAsString()
{
return this.timestamp.toString();
}
Message getReply()
{
return this.nextReply;
}
String getText()
{
return this.text;
}
void setLikes() //A like is added to the Message
{
this.likes=this.likes + 1;
}
Message getFatherMessage()
{
return this.fatherMessage;
}
static void setReply(Message e,Message a)
{
a.nextReply=e;
}
}