Skip to content

Commit

Permalink
Design domain #1
Browse files Browse the repository at this point in the history
  • Loading branch information
TravelerVihaan committed Feb 28, 2022
1 parent 2f7dd0c commit 1ac26a5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package com.github.travelervihaan.hogwarts.noticeboard.announcements;

import com.github.travelervihaan.hogwarts.noticeboard.reaction.Response;

import java.time.LocalDateTime;
import java.util.Objects;
import java.util.*;

public class Announcement {

private final LocalDateTime dateAdded;
private final LocalDateTime lastEdit;
private final String title;
private final String text;
private final List<Response> responses;

private final long authorId;

public Announcement(LocalDateTime dateAdded, LocalDateTime lastEdit, String title, String text, long authorId) {
public Announcement(LocalDateTime dateAdded, LocalDateTime lastEdit, String title,
String text, List<Response> responses, long authorId) {
this.dateAdded = dateAdded;
this.lastEdit = lastEdit;
this.title = title;
this.text = text;
this.responses = responses;
this.authorId = authorId;
}

Expand All @@ -40,6 +45,10 @@ public long getAuthorId() {
return authorId;
}

public List<Response> getResponses() {
return responses;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.travelervihaan.hogwarts.noticeboard.reaction;

class CommentResponse extends VoteResponse{
class CommentResponse extends VoteResponse {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.github.travelervihaan.hogwarts.noticeboard.reaction;

public interface Response {

void vote(boolean vote);

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
package com.github.travelervihaan.hogwarts.noticeboard.reaction;

class VoteResponse implements Response {

private Vote vote;

@Override
public void vote(boolean vote) {
this.vote = vote ? Vote.UP : Vote.DOWN;
}

public Vote getVote() {
return vote;
}

public void setVote(Vote vote) {
this.vote = vote;
}
}

0 comments on commit 1ac26a5

Please sign in to comment.