Me ajudem a um conseito de lista duplamente encadeada

1 resposta
nois_159

Olá pessoa!!.. por favor, não estou conseguindo passar o Remoção do arquivo..
eu não sei mais oque poderia ser sobre o erro..

muito obrigado pela atenção!!
public class Aluno {

    public String nome;
    public String curso;
    private int entrada;
    private int semestre;


    public Aluno(String nome, String curso) {
        this.nome = nome;
        this.curso = curso;
    }

    /**
     * @return the nome
     */
    public String getNome() {
        return nome;
    }

    /**
     * @param nome the nome to set
     */
    public void setNome(String nome) {
        this.nome = nome;
    }

    /**
     * @return the curso
     */
    public String getCurso() {
        return curso;
    }

    /**
     * @param curso the curso to set
     */
    public void setCurso(String curso) {
        this.curso = curso;
    }

    /**
     * @return the semestre
     */
    public int getSemestre() {
        return semestre;
    }

    /**
     * @param semestre the semestre to set
     */
    public void setSemestre(int semestre) {
        this.semestre = semestre;
    }

    /**
     * @return the entrada
     */
    public int getEntrada() {
        return entrada;
    }

    /**
     * @param entrada the entrada to set
     */
    public void setEntrada(int entrada) {
        this.entrada = entrada;
    }


}


public class Lista {


    private No inicio;
    private Object aux1;

    public Lista(){
        this(null);

    }

    public Lista(No aux){
        this.inicio = aux;
    }


    public void adicionainicio(Object valor, No ultimo){

        No novoNo = new No((No)valor);
        if (inicio != null) {
            novoNo.setProximo(novoNo);
            inicio = novoNo;
        }else{
            if (inicio == null) {
                inicio = novoNo;
                ultimo = novoNo;
            }
        }
        /*No novoNo = new No((No) valor);
        novoNo.setProximo(inicio);
        novoNo.setAnterior(null);
        inicio = novoNo;*/
    }


    public void adicionafim(No noaux1, No ultimo){
        No aux2 = null;
        if (inicio == null) {
            inicio = aux2;
            ultimo = aux2;     
    }
        if (ultimo != null) { 
            aux1 = noaux1.getAluno();  
            ultimo = noaux1;     
    }         
        /*No aux2 = inicio;
        while(aux2.getProximo()!=null){
        noaux1 = new No((No) noaux1.getAluno());
        aux2.setProximo(noaux1);
        aux2=noaux1;

        }*/

    }
    //****************************************************
    //Erro no meu REMOVE!!!!
    public void remove(Aluno aluno){
    No aux1 = inicio;
    while(aux1!=null){
    if(aux1.getAluno()==aluno){
        aux1.getAnterior().setProximo(aux1);
        aux1.getAnterior().setProximo(inicio)=aux1.setProximo();
        //aux1.getAnterior().setProximo()=aux1.getProximo();
        //aux1.setAnterior()=aux1.getProximo();
        //remove (aux1);*/
    }
    }
    }


    public void imprime(){
        while (inicio != null){
            System.out.println(inicio.getAluno());
            inicio = inicio.getProximo();
        }
    }

}



public class No {

    private No aluno;
    private No anterior;
    private No proximo;

    No(No aluno) {
        this.aluno = aluno;
    }

    public void No(No aluno){
        this.setAluno(aluno);
    }

    /**
     * @return the aluno
     */
    public Object getAluno() {
        return aluno;
    }

    /**
     * @param aluno the aluno to set
     */
    public void setAluno(No aluno) {
        this.aluno = aluno;
    }

    /**
     * @return the anterior
     */
    public No getAnterior() {
        return anterior;
    }

    /**
     * @param anterior the anterior to set
     */
    public void setAnterior(No anterior) {
        this.anterior = anterior;
    }

    /**
     * @return the proximo
     */
    public No getProximo() {
        return proximo;
    }

    /**
     * @param proximo the proximo to set
     */
    public void setProximo(No proximo) {
        this.proximo = proximo;
    }
}

me ajudem por favor!!!
tenha uma ótima semana.. xD

1 Resposta

Hebert_Coelho

Olá nois.

Vou fazer apenas uma pergunta… Qual o erro?

Criado 21 de setembro de 2010
Ultima resposta 21 de set. de 2010
Respostas 1
Participantes 2