Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. package Practica01;
  2.  
  3. import java.util.*;
  4. import java.io.*;
  5.  
  6. public class Test {
  7.  
  8. /**
  9. * @param args
  10. */
  11.  
  12. private static ArrayList<Integer> edificios = new ArrayList<Integer>();
  13.  
  14. public static void main(String[] args) {
  15.  
  16. long t;
  17.  
  18. System.out.println("\t AVISO \n Este programa ha sido desarrollado por: \n - Javier Imbernon Molina \n - Juan Miguel Gabarron Segura \n");
  19.  
  20. String dir = System.getProperty("user.dir")+File.separator+"CasosPrueba"+File.separator+"Practica01"+File.separator;
  21.  
  22. System.out.println("El programa trabaja con las siguientes condiciones: \n - Las entradas deberán estar en: "+dir+"\n - Las entradas serán de numeros enteros (int) \n");
  23.  
  24. generarEntradas(dir);
  25.  
  26. try{
  27.  
  28. FileWriter fw = new FileWriter(dir+"tiempos.txt");
  29. fw.write("Tiempos de creación de Skyline \n");
  30.  
  31. for(int i = 0; i<20; i++){
  32.  
  33. t = System.currentTimeMillis();
  34. Skyline s = new Skyline(dir+"entrada"+(i+1)+".txt",dir+"salida"+(i+1)+".txt");
  35. t=System.currentTimeMillis() - t;
  36. fw.write(edificios.get(i)+" edificios "+t+" milisegundos \n");
  37. }
  38.  
  39. fw.close();
  40.  
  41. }catch(Exception e){
  42. e.printStackTrace();
  43. }
  44.  
  45. }
  46.  
  47. public static void generarEntradas (String ruta){
  48.  
  49. Random rd = new Random();
  50. int x,y,z;
  51. int line;
  52.  
  53.  
  54. for(int i = 0; i<20; i++){
  55.  
  56. try{
  57.  
  58. FileWriter fw = new FileWriter(ruta+"entrada"+(i+1)+".txt");
  59.  
  60.  
  61. line = rd.nextInt();
  62. while(line == 0 || line == 100 || line == -100) line = rd.nextInt();
  63. if(line<0)line*=-1;
  64. line=line%100;
  65. edificios.add(line);
  66.  
  67. fw.write(line+"\n");
  68.  
  69. for(;line!=0;line--){
  70.  
  71. x=rd.nextInt();
  72.  
  73. if(x<0)x*=-1;
  74.  
  75. y=rd.nextInt();
  76.  
  77. if(y<0)y*=-1;
  78.  
  79. while(x==y){
  80. y=rd.nextInt();
  81. if(y<0)y*=-1;
  82. }
  83.  
  84. if(y<x){
  85. int aux = x;
  86. x=y;
  87. y=aux;
  88. }
  89.  
  90. z=rd.nextInt();
  91. if(z<0)z*=-1;
  92.  
  93. fw.write(x%10000+", "+y%10000+", "+z%10000+"\n");
  94.  
  95. }
  96.  
  97. fw.close();
  98.  
  99.  
  100. }catch(Exception e){
  101. e.printStackTrace();
  102. }
  103. }
  104. }
  105.  
  106. }
Add Comment
Please, Sign In to add comment