Regler problème même vote sur vote majoritaire

This commit is contained in:
Arimihanta 2021-07-15 04:33:55 +03:00
parent bcd6cfbd1f
commit 6a7ed064c4

View file

@ -106,7 +106,7 @@ public class VMThemeRESTFacade extends AbstractRESTFacade<VMTheme>{
choicesNotVoted.add(choice) ; choicesNotVoted.add(choice) ;
} }
} }
VMChoice newChoices[]=new VMChoice[choices.length] ; HashSet<VMChoice> newChoices = new HashSet<>();
if(!proposalTallyInterfaces.isEmpty()){ if(!proposalTallyInterfaces.isEmpty()){
ProposalTallyInterface []proposalTallyInterfacesArray=new ProposalTallyInterface[proposalTallyInterfaces.size()] ; ProposalTallyInterface []proposalTallyInterfacesArray=new ProposalTallyInterface[proposalTallyInterfaces.size()] ;
for(int i=0 ; i<proposalTallyInterfaces.size() ; i++){ for(int i=0 ; i<proposalTallyInterfaces.size() ; i++){
@ -121,24 +121,16 @@ public class VMThemeRESTFacade extends AbstractRESTFacade<VMTheme>{
for(ProposalResultInterface item : result.getProposalResults()){ for(ProposalResultInterface item : result.getProposalResults()){
VMChoice vmChoice=(VMChoice) choices[index] ; VMChoice vmChoice=(VMChoice) choices[index] ;
vmChoice.setRank(item.getRank()); vmChoice.setRank(item.getRank());
newChoices[item.getRank()-1]=vmChoice ; newChoices.add(vmChoice) ;
System.out.println(item.getRank()+" - "+newChoices[item.getRank()-1].getTitle());
index++ ; index++ ;
} }
} }
for(int i=0 ; i<choicesNotVoted.size() ; i++){ for(int i=0 ; i<choicesNotVoted.size() ; i++){
VMChoice vmChoice=choicesNotVoted.get(i) ; VMChoice vmChoice=choicesNotVoted.get(i) ;
vmChoice.setRank(newChoices.length-i); vmChoice.setRank(newChoices.size()-i);
newChoices[newChoices.length-(i+1)]= vmChoice ; newChoices.add(vmChoice) ;
} }
HashSet<VMChoice> setChoices = new HashSet<>(); theme.setChoices(newChoices);
System.out.println("Rang : ") ;
for(int i=0 ; i<newChoices.length ; i++){
System.out.println(i+" - "+newChoices[i].getTitle());
setChoices.add(newChoices[i]) ;
}
theme.setChoices(setChoices);
} }
} }