Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. public void llenarVector(int vector[]) throws Exception{
  2.  
  3. Random aleatorio=new Random();
  4. int n=Integer.MIN_VALUE;
  5. // System.out.println(vector.length);
  6. if (vector.length<=MAXIMO){
  7. for(int i=0; i<vector.length; i++)
  8. {
  9. boolean existe=true;
  10. while (existe)
  11. {
  12. n=aleatorio.nextInt(MAXIMO); /* Siguiente valor aleatorio */
  13. existe=comprobar_existe(vector,n);
  14. }
  15. vector[i]=n;
  16. }
  17.  
  18. }else
  19. throw new Exception("Maximo 100 elementos");
  20.  
  21. }
  22.  
  23. @Test
  24. public void testValidos() throws Exception{
  25. System.out.println("Llenar vector");
  26. int[] vector1 = new int[3];
  27. int[] vectorResult= new int[3];
  28. VectorUtilidades instancia1 =new VectorUtilidades();
  29. instancia1.llenarVector(vector1);
  30. assertArrayEquals(vector1,vector1);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement