SHARE
TWEET

Untitled

a guest Feb 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Practica 2: public void elimina (int year)
  2. public void elimina(int anio){
  3.  
  4.     Nodo aux = cabeza;
  5.  
  6.     // Si ELIMINAR primer dato
  7.     if(anio == aux.getDato().getAnios()){
  8.         cabeza = aux.getNext();
  9.         aux = null;
  10.     }
  11.  
  12. }
  13.  
  14. //Practica 2.1: Elimina ultimo dato
  15. public void elimina(int anio) {
  16.  
  17.     Nodo aux = cabeza;
  18.  
  19.     // Si ELIMINA ultimo dato
  20.     if(anio == aux.getNext().getDato().getAnios() && aux.getNext().getNext() == null){
  21.         cabeza.setNext(null);
  22.     }
  23.  
  24. }
  25.  
  26. // Practica 2.3: Elimina dato del medio
  27. public void elimina(int anio) {
  28.        
  29.     Nodo aux = cabeza;
  30.  
  31.     // Si ELIMINA ultimo dato
  32.     while(aux.getNext() != null) {
  33.         if(anio == aux.getNext().getDato().getAnios() && aux.getNext().getNext() != null){
  34.             Nodo tmp = aux.getNext().getNext();
  35.             aux.setNext(tmp);
  36.         }else{
  37.             aux = aux.getNext();
  38.         }
  39.     }
  40.        
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top