You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
945 B

package fr.mieuxvoter.mj;
import java.util.Arrays;
public class ProposalTally implements ProposalTallyInterface {
protected Long[] tally;
// Should we allow this as well?
//public ProposalTally() {}
public ProposalTally(Integer[] tally) {
int tallyLength = tally.length;
Long[] doublesTally = new Long[tallyLength];
for (int i = 0 ; i < tallyLength ; i++) {
doublesTally[i] = Long.valueOf(tally[i]);
}
setTally(doublesTally);
}
public ProposalTally(Long[] tally) {
setTally(tally);
}
public void setTally(Long[] tally) {
this.tally = tally;
}
@Override
public Long[] getTally() {
return this.tally;
}
@Override
public ProposalTallyInterface duplicate() {
return new ProposalTally(Arrays.copyOf(this.tally, this.tally.length));
}
@Override
public void moveJudgments(Integer fromGrade, Integer intoGrade) {
this.tally[intoGrade] += this.tally[fromGrade];
this.tally[fromGrade] = 0L;
}
}