Advertisement
JaimitoM

Untitled

May 14th, 2022
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1.  public ArrayList<Barrio> obtenerBarrioMaxProp() {
  2.        
  3.         // Determina el numero de propiedades del barrio que mas propiedades tiene
  4.         int max = 0;
  5.         for (int i = 0; i < barrios.size(); i++) {
  6.             int propiedades = barrios.get( i ).propiedades.size();
  7.             if (propiedades > max) {
  8.                 max = propiedades;
  9.             }
  10.         }
  11.  
  12.         // Guarda un arreglo con todos los barrios que tengan el maximo de propiedades.
  13.         ArrayList<Barrio> barriosMaxProp = new ArrayList<>();
  14.         for (int i = 0; i < barrios.size(); i++) {
  15.             int propiedades = barrios.get( i ).propiedades.size();
  16.             if (propiedades == max) {
  17.                 barriosMaxProp.add( barrios.get( i ) );
  18.             }
  19.         }
  20.  
  21.         return barriosMaxProp;
  22.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement