Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public int reacomodarCategoria(String cate) {
  2. int reacomodarCategoria = 0;
  3. ArrayList<Libro> PorCategoria = new ArrayList<Libro>();
  4.  
  5. for (int e=0;e<estantesPP.size();e++) {
  6. for (int l=0;l<estantesPP.get(e).libros.size();l++) {
  7. if (estantesPP.get(e).libros.get(l).categoria.equals(cate)){
  8. PorCategoria.add(estantesPP.get(e).libros.get(l));
  9. //estantesPP.get(e).libros.remove(estantesPP.get(e).libros.get(l));
  10. //estantesPP.get(e).espacioUsadoDelEstante=0;
  11. }
  12. }
  13. }
  14. //
  15.  
  16. //-----------------------------------------------------
  17.  
  18.  
  19. int auxES;
  20. String auxISBN;
  21. String auxT;
  22.  
  23. for (int i = 0; i < PorCategoria.size() - 1; i++) {// ordena nΒΊ de orden y espacio
  24.  
  25. for (int j = 0; j < PorCategoria.size() - i - 1; j++) {
  26. if (PorCategoria.get(j + 1).ancho < PorCategoria.get(j).ancho) {
  27. auxES = (int) PorCategoria.get(j + 1).ancho;
  28. auxISBN = PorCategoria.get(j + 1).isbn;
  29. auxT = PorCategoria.get(j + 1).titulo;
  30.  
  31. PorCategoria.get(j + 1).ancho = PorCategoria.get(j).ancho;
  32. PorCategoria.get(j + 1).isbn = PorCategoria.get(j).isbn;
  33. PorCategoria.get(j + 1).titulo = PorCategoria.get(j).titulo;
  34.  
  35. PorCategoria.get(j).ancho = auxES;
  36. PorCategoria.get(j).isbn = auxISBN;
  37. PorCategoria.get(j).titulo = auxT;
  38.  
  39. }
  40. }
  41. }
  42.  
  43.  
  44. for (Libro l:PorCategoria) {
  45. eliminarLibro(l.isbn);
  46. //ingresarLibro(l.isbn,l.categoria,l.titulo,l.ancho);
  47. }
  48.  
  49. for (Libro l:PorCategoria) {
  50. ingresarLibro(l.isbn,l.categoria,l.titulo,l.ancho);
  51. }
  52.  
  53. //
  54. // Retorna la cantidad de estantes liberados
  55. // Lanza excepcion si no hay ningun estante con la categoria
  56. // parametros: String, categoria
  57.  
  58. return reacomodarCategoria;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement