Advertisement
LucasSousa

Best (statistic provider)

Oct 21st, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package br.estatisticas;
  2.  
  3. import br.modelos.Solve;
  4. import java.util.ArrayList;
  5. import java.util.Collections;
  6.  
  7. /**
  8.  * Criado por Lucas Sousa em 21/10/2015.
  9.  */
  10. public class Best {
  11.  
  12.     private ArrayList<Solve> solves;
  13.  
  14.     public Best(ArrayList<Solve> solves){
  15.         this.solves = solves;
  16.     }
  17.  
  18.     private int getIndexOfBest(){
  19.         if (solves != null){
  20.             if (solves.size() >= 1){
  21.                 ArrayList<Long> longTimes = new ArrayList<>();
  22.                 for (Solve s : solves){
  23.                     longTimes.add(s.getTime());
  24.                 }
  25.                 return longTimes.indexOf(Collections.min(longTimes));
  26.             }
  27.         }
  28.         return 0;
  29.     }
  30.  
  31.     public long getBestValue(){
  32.         ArrayList<Long> longTimes = new ArrayList<>();
  33.         for (Solve s : solves){
  34.             longTimes.add(s.getTime());
  35.         }
  36.         return longTimes.get(getIndexOfBest());
  37.     }
  38.  
  39.     public String getBestSolve(){
  40.         return solves.get(getIndexOfBest()).toString();
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement