added get path
This commit is contained in:
@@ -6,10 +6,9 @@ import java.util.Vector;
|
||||
|
||||
public class JodelPost {
|
||||
// id of the post
|
||||
private Long id;
|
||||
public Long id;
|
||||
// id of the author in db
|
||||
private Long authorID;
|
||||
|
||||
// anonymized authorID
|
||||
public Long anonymousID;
|
||||
// title of the post
|
||||
@@ -53,8 +52,26 @@ public class JodelPost {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: create constructor
|
||||
public JodelPost(long id) {
|
||||
this.authorID = id;
|
||||
// add a comment if it is really a comment
|
||||
public boolean addComment(JodelPost post, long parent) {
|
||||
// check if the post a direct comment
|
||||
if (parent == this.id) {
|
||||
// add the comment
|
||||
this.comments.add(post);
|
||||
// return success
|
||||
return true;
|
||||
}
|
||||
// recursively repeat this for all comments
|
||||
for (JodelPost comment : this.comments) {
|
||||
// return success if the post is a comment on a child
|
||||
if (comment.addComment(post, parent)) return true;
|
||||
}
|
||||
// return no success
|
||||
return false;
|
||||
}
|
||||
|
||||
// constructor with private authorID
|
||||
public JodelPost(long authorID) {
|
||||
this.authorID = authorID;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user