-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiscussion.java
50 lines (39 loc) · 917 Bytes
/
Discussion.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
import java.io.*;
import java.util.*;
public class Discussion implements Serializable
{
private String discTitle = "";
private Vector<Comment> commentList = new Vector<Comment>();
public Discussion() {}
public Discussion(String title){
discTitle = title;
}
public String getTitle(){
return discTitle;
}
public void setTitle(String title){
discTitle = title;
}
public Comment getComment(int id){
return commentList.elementAt(id);
}
public void addComment(Comment comment){
comment.setParent(this);
commentList.add(comment);
sortComments();
}
public void removeComment(Comment comment){
commentList.remove(comment);
sortComments();
}
public Vector<Comment> getAllComments(){
return commentList;
}
public void sortComments(){
Collections.sort(commentList);
Collections.reverse(commentList);
}
public String toString() {
return discTitle;
}
}