Initial Commit
Initial commit of project.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollResults extends Command
|
||||
{
|
||||
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return "Will show current results of a poll and percentages of votes per choice"; }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String results = "";
|
||||
int totalVotes = 0;
|
||||
ArrayList<KittyPoll> votes = guild.choices;
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
totalVotes += votes.get(i).votes;
|
||||
}
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
|
||||
results += votes.get(i).votes + " people voted for `" + votes.get(i).choice + "` with `" + (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100) + "%`!\n";
|
||||
}
|
||||
|
||||
res.Call(results);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user