-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComment.java
89 lines (78 loc) · 2.37 KB
/
Comment.java
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
/**
* This class is going to allow for commenting and assign users to comments
* @author word.exe
*/
import java.util.ArrayList;
public class Comment {
private String authorName;
private String commentContent;
private ArrayList<Comment> replies;
/**
* This is going to assign comments by author name and the comment content
* @param authorName The name of the author of the comment
* @param commentContent The comment content
*/
public Comment(String authorName, String commentContent) {
this.authorName = authorName;
this.commentContent = commentContent;
replies = new ArrayList<Comment>();
}
/**
* This is going to allow authors to reply to comments
* @param replyComment The comment content that is used for the reply
*/
public void reply(Comment replyComment) {
replies.add(replyComment);
}
/**
* This is going to allow the author to view replies to comments
*/
public void viewReplies() {
for(Comment x: replies) {
System.out.println(x.getReplies() + "\n");
}
}
/**
* This is going to pull the authors name of the comment
* @return the authors name is returned
*/
public String getAuthorName() {
return this.authorName;
}
/**
* This is going to set the authors name
* @param authorName the name of the author as a string
*/
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
/**
* This is going to get the content of the comment
* @return the comment content
*/
public String getCommentContent() {
return this.commentContent;
}
/**
* This is going to set the comment content
* @param commentContent the content of the comment
*/
public void setCommentContent(String commentContent) {
this.commentContent = commentContent;
}
/**
* This is going to get the replies to the comment as a list
* @return the replies
*/
public ArrayList<Comment> getReplies() {
return this.replies;
}
/**
* This is going to create a string to return the comment
* @return the name and the comment content
*/
public String toString() {
return this.getAuthorName() + "\n"
+ this.getCommentContent() + "\n";
}
}