refacto: rename TallyNormalized → NormalizedTally

pull/9/head
Dominique Merle 3 years ago
parent 169c5fc33e
commit 332614d2ea

@ -3,9 +3,9 @@ package fr.mieuxvoter.mj;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
public class TallyNormalized extends Tally implements TallyInterface { public class NormalizedTally extends Tally implements TallyInterface {
public TallyNormalized(ProposalTallyInterface[] proposalsTallies) { public NormalizedTally(ProposalTallyInterface[] proposalsTallies) {
super(proposalsTallies); super(proposalsTallies);
Integer amountOfProposals = getAmountOfProposals(); Integer amountOfProposals = getAmountOfProposals();
@ -21,13 +21,13 @@ public class TallyNormalized extends Tally implements TallyInterface {
// Normalize proposals to the LCM // Normalize proposals to the LCM
ProposalTally[] normalizedTallies = new ProposalTally[amountOfProposals]; ProposalTally[] normalizedTallies = new ProposalTally[amountOfProposals];
for (int i = 0 ; i < amountOfProposals ; i++ ) { for (int i = 0 ; i < amountOfProposals ; i++) {
ProposalTallyInterface proposalTally = proposalsTallies[i]; ProposalTallyInterface proposalTally = proposalsTallies[i];
ProposalTally normalizedTally = new ProposalTally(proposalTally); ProposalTally normalizedTally = new ProposalTally(proposalTally);
BigInteger factor = amountOfJudges.divide(proposalTally.getAmountOfJudgments()); BigInteger factor = amountOfJudges.divide(proposalTally.getAmountOfJudgments());
Integer amountOfGrades = proposalTally.getTally().length; Integer amountOfGrades = proposalTally.getTally().length;
BigInteger[] gradesTallies = normalizedTally.getTally(); BigInteger[] gradesTallies = normalizedTally.getTally();
for (int j = 0 ; j < amountOfGrades; j++ ) { for (int j = 0 ; j < amountOfGrades; j++) {
gradesTallies[j] = gradesTallies[j].multiply(factor); gradesTallies[j] = gradesTallies[j].multiply(factor);
} }
normalizedTallies[i] = normalizedTally; normalizedTallies[i] = normalizedTally;

@ -75,7 +75,7 @@ class MajorityJudgmentDeliberatorTest {
if ("StaticDefault".equalsIgnoreCase(mode)) { if ("StaticDefault".equalsIgnoreCase(mode)) {
tally = new TallyWithDefaultGrade(tallies, amountOfParticipants, datum.getInt("default")); tally = new TallyWithDefaultGrade(tallies, amountOfParticipants, datum.getInt("default"));
} else if ("Normalized".equalsIgnoreCase(mode)) { } else if ("Normalized".equalsIgnoreCase(mode)) {
tally = new TallyNormalized(tallies); tally = new NormalizedTally(tallies);
} else { } else {
tally = new Tally(tallies, amountOfParticipants); tally = new Tally(tallies, amountOfParticipants);
} }

Loading…
Cancel
Save