package mafiaserver;

import java.util.HashMap;

/**
 * VoteSequence.java
 * Contains the VoteSequence class
 * @author Cory Gehr (cmg5573)
 */
public class VoteSequence extends Thread {
    
    private final HashMap<String, String> votes; // List of votes
    
    /**
     * VoteSequence()
     * Constructor for the VoteSequence class
     */
    public VoteSequence() {
        this.votes = new HashMap();
    }
    
    /**
     * addVote()
     * Adds a vote for a player
     * @param client Player Voting
     * @param vote Vote Value
     */
    public void addVote(RemoteParticipant client, String vote) {
        // Add or overwrite current vote for the client, if they can vote
        if(client.canVote()) {
            this.votes.put(client.getUsername(), vote);
        }
        else {
            client.pushOutput("You cannot vote on this.");
        }
    }
}

@@ -871,10 +871,791 @@
 %7D%0A    %7D%0A
+    %0A    /**%0A     * getResult()%0A     * Gets the result of the vote%0A     * @return Vote Result, or NULL if there is a tie%0A     */%0A    public String getResult() %7B%0A        HashMap%3CString, Integer%3E results = new HashMap();%0A        %0A        String winner = null;%0A        int winningVoteNums = 0;%0A        %0A        // First, tally the votes%0A        for(String vote : this.votes.values()) %7B%0A            if(results.containsKey(vote)) %7B%0A                results.put(vote, results.get(vote)+1);%0A            %7D%0A            else %7B%0A                results.put(vote, 1);%0A            %7D%0A            %0A            if(results.get(vote) %3E winningVoteNums) %7B%0A                winningVoteNums = results.get(vote);%0A                winner = vote;%0A            %7D%0A        %7D%0A        %0A        return winner;%0A    %7D%0A
 %7D%0A

Add getResult() to VoteSequence