Advertisement
fmbalvarez

Guía 6 - Ejercicio 2a-2b Nightly Build

May 10th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. /**
  4.  * Created by felipealvarez on 10/5/15.
  5.  */
  6. public class Jugueteria {
  7.  
  8.     public Object regaloAlAzar(int[] o){
  9.         ArrayList empleados = new ArrayList();
  10.         for (int i = 0; i < o.length; i++) {
  11.             empleados.add(o);
  12.         }
  13.         Random random = new Random();
  14.         int aleatorio = random.nextInt(empleados.size() + 1);
  15.         return empleados.get(aleatorio);
  16.     }
  17.  
  18.     /**
  19.      * b)  JET ha decidido que cada nuevo juguete recibirá el primer nombre
  20.      de un empleado, y que cada nombre se usará sólo una vez. Nos
  21.      piden enumerar todos los valores posibles de primeros nombres.
  22.      */
  23.  
  24.     public int nombreJuguetes(Empleados[] e){
  25.         HashMap listaDeJuguetes = new HashMap();
  26.         Juguete[] juguetes = new Juguete[e.length];
  27.         int cantidadValoresPosibles = 0;
  28.         for (int i = 0; i < e.length; i++) {
  29.             juguetes[i] = new Juguete();
  30.             listaDeJuguetes.put(e[i].getNombre(),juguetes[i]);
  31.             cantidadValoresPosibles++;
  32.         }
  33.         return cantidadValoresPosibles;
  34.     }
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement