Advertisement
Guest User

Untitled

a guest
May 25th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1.     public static void BorrarMascotaDavis() {
  2.         int i = 0;
  3.         int j = 0;
  4.         int aux = "";
  5.        
  6.         System.out.println("Introduzca ID de la mascota que deseas borrar");
  7.         aux = sc.nextInt();
  8.         boolean encontrado = false;
  9.        
  10.         for (i = 0; i < arrayClientes.size(); i++) {
  11.             for (j = 0; j < arrayClientes.get(i).arrayMascotas.size; j++){
  12.                 Mascotas pepe = arrayClientes.get(i).arrayMascotas.get(j);
  13.                 if (pepe.getIdMasc().equals(aux)) {
  14.                     arrayClientes.get(i).arrayMascotas.remove(j);
  15.                     encontrado = true;
  16.                     break;
  17.                 }
  18.             }
  19.             if (encontrado) break;
  20.         }
  21.        
  22.         if (encontrado) System.out.println("Mascota borrada correctamente");
  23.         else System.out.println("Mascota no encontrada");
  24.        
  25.     }
  26.    
  27.    
  28.     // como tenias el switch en el propio menu y eso generaba un bucle infinito cree otro submenu con el switch para Procesar los datos
  29.         public static void procesarMenumascotas(int opcion) {
  30.             switch (opcion) {
  31.             case 1:
  32.                 System.out.println("Indtoruce el DNI del dueño de la mascota.\n");
  33.                 peticionDatos(4);//le mando la opcion 4 por que es por la que va a ir por el switch del metodo final.
  34.                 break;
  35.             case 2:
  36.                 mostrarTodasMascotas();
  37.                 break;
  38.             case 3:
  39.                 peticionDatos(5);
  40.                 break;
  41.             case 4:
  42.                 modificarMascota();
  43.                 break;
  44.             case 5:
  45.                 //borrarMascota();
  46.                 borrarMascotaDavis();
  47.                 break;
  48.             default:
  49.             }
  50.            
  51.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement