Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion solutions/java/src/stackoverflow/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,4 +82,4 @@ private int generateId() {
public Answer getAcceptedAnswer() {
return acceptedAnswer;
}
}
}