Advertisement
LucasSousa

OverallMean (statistic provider)

Oct 21st, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. package br.estatisticas;
  2.  
  3. import br.modelos.Solve;
  4. import java.util.ArrayList;
  5.  
  6. /**
  7.  * Criado por Lucas Sousa em 21/10/2015.
  8.  */
  9. public class OverallMean {
  10.  
  11.     private ArrayList<Solve> solves;
  12.  
  13.     public OverallMean(ArrayList<Solve> solves) {
  14.         this.solves = solves;
  15.     }
  16.  
  17.     public long getOverallMeanValue() {
  18.         if (solves != null) {
  19.             if (solves.size() > 0) {
  20.                 ArrayList<Long> longValues = new ArrayList<>();
  21.                 for (Solve s : solves) {
  22.                     longValues.add(s.getTime());
  23.                 }
  24.                 long somatorio = 0;
  25.                 for (long x : longValues) {
  26.                     somatorio += x;
  27.                 }
  28.                 return (somatorio / longValues.size());
  29.             }
  30.         }
  31.         return 0;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement