Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Metodo creado para eliminar un objeto en base al rut ingresado en el scanner
- */
- public void eliminarPasajero()
- {
- if (lista2.isEmpty())
- {
- System.out.println("-------------------------------------------------");
- System.err.println("¡Error! Lista vacia.");
- System.out.println("-------------------------------------------------");
- MenuPrincipal();
- }
- else
- {
- leer = new Scanner(System.in);
- System.out.println("RUT del pasajero que quiere eliminar: ");
- setDato(leer.next());
- for(int x=0;x<lista2.size();x++)
- {
- Pasajero pa=lista2.get(x);
- if(pa.getRUT().equals(getDato()))
- {
- lista2.remove(x);
- System.out.println("-------------------------------------------------");
- System.err.println("Pasajero con RUT: "+getDato()+" eliminado exitosamente!");
- System.out.println("-------------------------------------------------");
- MenuPrincipal();
- }
- else
- {
- System.err.println("¡Error! el RUT ingresado no existe. ");
- MenuPrincipal();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment