Netbeans - almacenar y eliminar informacion de un estudiante utilizando solo 1 arraylist para almacenar informa

 
Vista:

almacenar y eliminar informacion de un estudiante utilizando solo 1 arraylist para almacenar informa

Publicado por Jair (1 intervención) el 03/04/2019 04:06:58
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import java.util.*;
 
 
public class Estudiante1{
    private  String courseName;
    private boolean opcion;
    private int opsion;
    private String[] students = new String [100];
    private int numberOfStudents;
 
    private String a_paterno;
    private String a_materno;
    private String anio_nacimiento;
    private String correo;
 
    public void addStudent(String student){
        students[numberOfStudents] = student;
        numberOfStudents++;
    }
 
    public void deletStudent(String student){
        students[numberOfStudents] = student;
        numberOfStudents--;
    }
 
//    public void deletStudent(String n_stu){
//        for(int i = 0; i< getNumberOfStudents(); i++){
//            if(n_stu.equals(students[i])){
//                System.out.println("EL NOMBRE QUE ESCRIBIO SI EXISTE EN EL ARRAYLIST NUMERO : "+(i+1));
//            students[i] = "";
//        }else{
//            System.out.println("EL NOMBRE QUE ESCRIBIO NO EXISTE EN EL ARRAYLIST "+(i+1));
//            }
//        }
//    }
 
    public void setStudents(String[] students) {
        this.students = students;
    }
    public String[] getStudents() {
        return students;
    }
//-------------------------------------------------------
    public void setNumberOfStudents(int numberOfStudents) {
        this.numberOfStudents = numberOfStudents;
    }
    public int getNumberOfStudents() {
        return numberOfStudents;
    }
//-------------------------------------------------------
    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }
    public String getCourseName() {
        return courseName;
    }
//-------------------------------------------------------
    public void setOpcion(int opsion){
        this.opsion = opsion;
    }
    public void setOpcion(boolean opcion) {
        this.opcion = opcion;
    }
    public int getOpcion(){
        return opsion;
    }
//-------------------------------------------------------
    public void setOpsion(int opsion) {
        this.opsion = opsion;
    }
    public int getOpsion() {
        return opsion;
    }
//-------------------------------------------------------
    public String getA_paterno() {
        return a_paterno;
    }
    public void setA_paterno(String a_paterno) {
        this.a_paterno = a_paterno;
    }
//-------------------------------------------------------
    public String getA_materno() {
        return a_materno;
    }
    public void setA_materno(String a_materno) {
        this.a_materno = a_materno;
    }
//-------------------------------------------------------
    public String getAnio_nacimiento() {
        return anio_nacimiento;
    }
    public void setAnio_nacimiento(String anio_nacimiento) {
        this.anio_nacimiento = anio_nacimiento;
    }
//-------------------------------------------------------
    public String getCorreo() {
        return correo;
    }
    public void setCorreo(String correo) {
        this.correo = correo;
    }
//-------------------------------------------------------
 
 
 
 
    public boolean guardarOpcion() {
        boolean opcion = false;
        if (opsion<=1){
            opcion=true;
        }else{
            opcion=false;
        }
        return opcion;
    }
 
 
 
    public static void main(String[] args) {
        Estudiante1 c1= new Estudiante1();
        Scanner scan = new Scanner(System.in);
        Estudiante1[] estudiante = new Estudiante1 [100];
//        Estudiante1[] students = new String [100];
 
        int opc=0;
        while (opc!=6){
 
            System.out.println("-----MENU------");
            System.out.println("1 NOMBRE DEL CURSO");
            System.out.println("2 AGREGAR ESTUDIANTE");
            System.out.println("3 MOSTRAR ESTUDIANTE");
            System.out.println("4 MOSTRAR TOTAL ESTUDIANTES");
            System.out.println("5 ELIMINAR UN ESTUDIANTE");
            System.out.println("6 SALIR");
            opc = scan.nextInt();
            switch (opc){
                case 1:
                    System.out.println("CURSO : ");
                    c1.courseName = scan.next();
                break;
                case 2:
                    System.out.println("NOMBRE DEL ESTUDIANTE");
                    String a = scan.next();
                    c1.addStudent(a);
                    System.out.println("APELLIDO PATERNO");
                    String b = scan.next();
                    c1.setA_paterno(b);
                    System.out.println("APELLIDO MATERNO");
                    String c = scan.next();
                    c1.setA_materno(c);
                    System.out.println("AÑO NACIMIENTO");
                    String d = scan.next();
                    c1.setAnio_nacimiento(d);
                    System.out.println("E-MAIL");
                    String e = scan.next();
                    c1.setCorreo(e);
 
                break;
                case 3:
                    System.out.println(c1.courseName);
                    for(int i=0; i < c1.getNumberOfStudents(); i++){
//                    System.out.println("ESTUDIANTE "+(i+1)+": "+c1.students[i]);
 
                    estudiante[i].getA_materno();
                    estudiante[i].getA_paterno();
//                    System.out.println( " nombre del estudiante " +c1.students[i]+ "\n apellido paterno del estudiante " + c1.a_materno() + "\n apellido materno del estudiante " + c1.getA_materno()+ "\n año nacimiento del estudiante " +c1.getAnio_nacimiento()+ "\n correo del estudiante " +c1.getCorreo()+ " " );
                }
 
                break;
                case 4:
                    System.out.println("NUMERO DE ESTUDIANTES: "+c1.getNumberOfStudents() );
                break;
                case 5:
                System.out.println("¿ESTAS SEGURO DE ELIMINAR A UN ESTUDIANTE?");
                System.out.println("1 PARA ACEPTAR");
                System.out.println("2 PARA RECHAZAR");
                int opsion = scan.nextInt();
                c1.setOpcion(opsion);
                if (opsion<=1){
                System.out.println("ESCRIBE EL ESTUDIANTE QUE DESEA ELIMINAR");
                String n_stu = scan.next();
                c1.deletStudent(n_stu);
                }else{
                    break;
                }
                break;
                default: System.out.println("ADIOS");
                break;
            }
        }
    }
}
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