diff --git a/solutions/java/src/stackoverflow/Question.java b/solutions/java/src/stackoverflow/Question.java index 039ff7cb..9c768458 100644 --- a/solutions/java/src/stackoverflow/Question.java +++ b/solutions/java/src/stackoverflow/Question.java @@ -44,6 +44,7 @@ public synchronized void acceptAnswer(Answer answer) { @Override public void vote(User voter, VoteType type) { + if(voter.equals(author)) return; //throw error -> Author shouldn't be allowed to vote votes.removeIf(v -> v.getVoter().equals(voter)); votes.add(new Vote(voter, type)); author.updateReputation(5 * (type == VoteType.UPVOTE ? 1 : -1)); // +5 for upvote, -5 for downvote @@ -81,4 +82,4 @@ private int generateId() { public Answer getAcceptedAnswer() { return acceptedAnswer; } -} \ No newline at end of file +}