public void agregarInicio(JuegoNodo juego) { if (verificarCabeza() == true) { cabeza = juego; numeroRegistros++; } else { cabeza.setAnterior(juego); juego.setSiguiente(cabeza); cabeza = juego; numeroRegistros++; } }
public void eliminarNNodos(int CantidadaEliminar) { if (verificarCabeza() == true) { throw new Exception("No hay ningun juego"); } else if (CantidadaEliminar <= 0) { throw new Exception("La cantidad especificada no es valida debe ser mayor a cero"); } else if (CantidadaEliminar > numeroRegistros) { throw new Exception("La cantidad a eliminar de ser menor o igual a: " + numeroRegistros); } else { int contador = 0; int posicion = 1; if (numeroRegistros != CantidadaEliminar) { posicion = numeroRegistros - CantidadaEliminar; } JuegoNodo temp = cabeza; while (temp != null) { contador++; if (contador == posicion) { temp.setSiguiente(null); numeroRegistros = numeroRegistros - CantidadaEliminar; break; } temp = temp.getSiguiente(); } } }