Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.estatisticas;
- import br.modelos.Solve;
- import java.util.ArrayList;
- import java.util.Collections;
- /**
- * Criado por Lucas Sousa em 21/10/2015.
- */
- public class OverallAverage {
- private ArrayList<Solve> solves;
- public OverallAverage(ArrayList<Solve> solves){
- this.solves = solves;
- }
- public long getOverallAverage(){
- if (solves != null){
- if (solves.size() >= 3){
- ArrayList<Long> longTimes = new ArrayList<>();
- for (Solve s : solves){
- longTimes.add(s.getTime());
- }
- longTimes.remove(Collections.max(longTimes));
- longTimes.remove(Collections.min(longTimes));
- long somatorio = 0;
- for (long x : longTimes){
- somatorio += x;
- }
- return (somatorio / longTimes.size());
- }
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement