forked from raghaddmahgoub/OOP-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComment.java
More file actions
59 lines (50 loc) · 1.59 KB
/
Comment.java
File metadata and controls
59 lines (50 loc) · 1.59 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
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Comment extends Text{
////////////////////////////////////////////ATTRIBUTES//////////////////////////////////////
private List<Reply> userReplies;
private static int Id=0;
public void setCommentId(int commentId) {
this.commentId = commentId;
}
private int commentId;
//////////////////////////////////////////CONSTRUCTORS///////////////////////////////////////////
public Comment( String content) {
this.cntReacts = 0;
commentId=Id;
Id++;
this.userReplies = new ArrayList<>();
this.content =content;
}
////////////////////////////////////////////METHODS///////////////////////////////////////////
public void addReply(Reply newReply){
userReplies.add(newReply);
}
public int getId(){
return commentId;
}
public List<Reply> getUserReplies(){
return userReplies;
}
public Reply getReply(int replyId){
return getUserReplies().get(replyId);
}
public void editReply(int replyId,String newContent){
getReply(replyId).setContent(newContent);
System.out.println("Reply edited");
}
public void deleteReply(int replyId){
getUserReplies().remove(getReply(replyId));
System.out.println("Reply deleted");
}
@Override
public void addReact() {
cntReacts++;
}
@Override
public int getReacts() {
return cntReacts;
}
}