Java - Función Eliminar en Java

 
Vista:
Imágen de perfil de Abi

Función Eliminar en Java

Publicado por Abi (22 intervenciones) el 11/06/2015 01:47:09
Hola!!
Alguien que me ayude o me explique como puedo hacer la funcion eliminar de este codigo xfaa

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package nodos;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
 
 
public class Lista
{
    Nodos cab;
    File f = new File("C:\\Users\\Usuario\\Documents\\NetBeansProjects\\Nodos\\nodos.txt");
 
    public  void cargar() throws Exception
    {
        if(f.exists())
        {
           ObjectInputStream ois = null ;
            try (FileInputStream fis = new FileInputStream(f))
            {
                ois = new ObjectInputStream (fis);
                cab=(Nodos)ois.readObject();
            }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
          ois.close();
        }else
        {
            f.createNewFile();
        }
    }
    void insertar(String n, double no)
            {
               if(cab==null) {
                   cab=new Nodos(n,no);
               }else{
                   Nodos temp= new Nodos(n,no);
                   temp.enlace=cab;
                   cab=temp;
               }
            }
    void guardar() throws Exception
    {
        FileOutputStream fos = new FileOutputStream(f);
            ObjectOutputStream oos = new ObjectOutputStream (fos);
            oos.writeObject(cab);
            fos.close();
            oos.close();
    }
    void mostrar()
    {
        Nodos aux= cab;
        while(aux!= null)
        {
            System.out.println(aux.getNombre()+" "+aux.getNota());
            aux = aux.enlace;
        }
    }
    void buscar(String nombreBuscar)
            {
               Nodos aux =cab;
               boolean bandera=false;
                System.out.println("-------------------------");
                while(aux != null)
                {
                if(aux.getNombre().equals(nombreBuscar))
                {
                    System.out.println("Encontrado: \n\t"+aux.getNombre()+"  "+aux.getNota());
 
                    bandera=true;
                }
                aux = aux.enlace;
 
            }
             if(!bandera)
             {
                 System.out.println("No encontrado ");
             }
                System.out.println("--------------------------------");
            }
 
    void promedio()
    {
        Nodos aux= cab;
        double sumaNota=0.0;
        int numeroAlumnos=0;
        DecimalFormat df= new DecimalFormat("0.00");
        while(aux != null)
        {
            sumaNota += (float)aux.getNota();
            numeroAlumnos++;
            aux = aux.enlace;
        }
        System.out.println("-------------------------------------");
        System.out.println("Promedio\n\t Alumnos: "+numeroAlumnos+" \n\tPromedio: "
                +df.format(sumaNota/numeroAlumnos));
        System.out.println("-------------------------------------");
    }
    void alta()
    {
       int i = 0, nota = 0;
        float sum = 0, alta = 0;
 
        Nodos aux= cab;
        while(aux!= null)
        {
            if (aux.getNota() > alta) {
                alta = (float) aux.getNota();
 
                sum = (float) (sum + aux.getNota());
                i++;
            }
 
            aux = aux.enlace;
        }
        System.out.println("La nota mas alta es " + alta);
 
    }
 
    void baja()
    {
        Nodos aux= cab;
        int i=1, nota=1;
        float sum=0,  baja=11;
 
 
        while(aux!= null)
        {
            if (aux.getNota() < baja) {
                baja = (float) aux.getNota();
 
                sum = (float) (sum + aux.getNota());
                i++;
            }
 
            aux = aux.enlace;
        }
        System.out.println("La nota mas baja es " + baja);
 
    }
 
  void eliminar()
    {
 
   // aqii no se como hacerlo
   }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder