Class Poll
java.lang.Object
net.flectone.pulse.module.command.poll.model.Poll
A running poll and the votes cast so far.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]How many votes each option has.intlongintgetId()longlonggetTitle()booleanisEnded()Whether voting has closed.booleanbooleanrepeat()Whether the poll is due to be announced again.intRecords a vote, withdrawing the voter's previous one when only a single choice is allowed.
-
Constructor Details
-
Poll
public Poll(int id, int creator, long endTime, long repeatTime, boolean multipleVote, String title, List<String> answers) Creates a poll.- Parameters:
id- the database idcreator- the player who started itendTime- when voting closes, in millisecondsrepeatTime- how often it is re-announced, in millisecondsmultipleVote- whether a voter may pick several answerstitle- the questionanswers- the options to vote on
-
-
Method Details
-
vote
Records a vote, withdrawing the voter's previous one when only a single choice is allowed.- Parameters:
fPlayer- the voternumberVote- the chosen option- Returns:
- whether the vote was cast, changed or withdrawn
-
getCountAnswers
public int[] getCountAnswers()How many votes each option has.- Returns:
- the tallies, in option order
-
isEnded
public boolean isEnded()Whether voting has closed.- Returns:
- true if the poll is over
-
repeat
public boolean repeat()Whether the poll is due to be announced again.- Returns:
- true if it should be re-announced now
-
getId
public int getId() -
getCreator
public int getCreator() -
getEndTime
public long getEndTime() -
getRepeatTime
public long getRepeatTime() -
isMultipleVote
public boolean isMultipleVote() -
getTitle
-
getAnswers
-
getVotesMap
-
getNextRepeat
public long getNextRepeat()
-