Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int reacomodarCategoria(String cate) {
- int reacomodarCategoria = 0;
- ArrayList<Libro> PorCategoria = new ArrayList<Libro>();
- for (int e=0;e<estantesPP.size();e++) {
- for (int l=0;l<estantesPP.get(e).libros.size();l++) {
- if (estantesPP.get(e).libros.get(l).categoria.equals(cate)){
- PorCategoria.add(estantesPP.get(e).libros.get(l));
- //estantesPP.get(e).libros.remove(estantesPP.get(e).libros.get(l));
- //estantesPP.get(e).espacioUsadoDelEstante=0;
- }
- }
- }
- //
- //-----------------------------------------------------
- int auxES;
- String auxISBN;
- String auxT;
- for (int i = 0; i < PorCategoria.size() - 1; i++) {// ordena nΒΊ de orden y espacio
- for (int j = 0; j < PorCategoria.size() - i - 1; j++) {
- if (PorCategoria.get(j + 1).ancho < PorCategoria.get(j).ancho) {
- auxES = (int) PorCategoria.get(j + 1).ancho;
- auxISBN = PorCategoria.get(j + 1).isbn;
- auxT = PorCategoria.get(j + 1).titulo;
- PorCategoria.get(j + 1).ancho = PorCategoria.get(j).ancho;
- PorCategoria.get(j + 1).isbn = PorCategoria.get(j).isbn;
- PorCategoria.get(j + 1).titulo = PorCategoria.get(j).titulo;
- PorCategoria.get(j).ancho = auxES;
- PorCategoria.get(j).isbn = auxISBN;
- PorCategoria.get(j).titulo = auxT;
- }
- }
- }
- for (Libro l:PorCategoria) {
- eliminarLibro(l.isbn);
- //ingresarLibro(l.isbn,l.categoria,l.titulo,l.ancho);
- }
- for (Libro l:PorCategoria) {
- ingresarLibro(l.isbn,l.categoria,l.titulo,l.ancho);
- }
- //
- // Retorna la cantidad de estantes liberados
- // Lanza excepcion si no hay ningun estante con la categoria
- // parametros: String, categoria
- return reacomodarCategoria;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement