31 lines
745 B
Java
31 lines
745 B
Java
package implementacoes;
|
|
|
|
import java.rmi.RemoteException;
|
|
import java.rmi.server.UnicastRemoteObject;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import interfaces.ApuracaoInterface;
|
|
|
|
public class ApuracaoImpl extends UnicastRemoteObject implements ApuracaoInterface {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
public ApuracaoImpl() throws RemoteException {
|
|
super();
|
|
}
|
|
|
|
private Map<Integer, Integer> quantidade = new HashMap<>();
|
|
|
|
@Override
|
|
public Map<Integer, Integer> calcularVotos(List<Integer> votos) {
|
|
votos.forEach(voto -> {
|
|
int count = (int) votos.stream().filter(p -> p.equals(voto)).count();
|
|
quantidade.put(voto, ((100 * count) / votos.size()));
|
|
});
|
|
|
|
return quantidade;
|
|
}
|
|
}
|