Pasar variables locales a globales y usarlas
Publicado por Alejandro (5 intervenciones) el 10/05/2018 22:43:51
Buen día comunidad. hoy vengo con una duda, necesito pasar unos vectores locales a globales y utilizarlos en otro código del mismo paquete, espero puedan ayudarme.
Los vectores de: "Nombre, Documento, Hora de ingreso Etc..." Los edité en la clase de "Registro" y esos valores los necesito pasar a la clase de "Información"
Gracias de atemano.
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
package proyecto_final;
import javax.swing.*;
import java.util.Scanner;
public class Proyecto_final {
int[] documento = new int[10];
String[] nombre = new String[10];
String[] tipo = new String[10];
String[] hora_de_ingreso = new String[10];
String[] hora_de_salida = new String[10];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int opcion;
boolean bucle = true;
while (bucle) {
opcion = Integer.parseInt(JOptionPane.showInputDialog("Ingresa la opción a escoger "
+ "\n 1. Registro de ingreso "
+ "\n 2. Información total "
+ "\n 3. Cantidad "
+ "\n 4. Modificar "
+ "\n 5. Porcenaje "
+ "\n 6. Más tiempo "
+ "\n 7. Administrativos "
+ "\n 8. Promedio "
+ "\n 9. Documento "
+ "\n 0. Finalizar"));
switch (opcion) {
case 1:
Registro ingreso = new Registro();
ingreso.ingreso();
break;
case 2:
Informacion total = new Informacion();
total.total();
1
2
3
4
5
6
7
8
9
10
11
12
import java.util.Scanner;
public class Registro {
public void ingreso() {
Scanner sc = new Scanner(System.in);
int[] documento = new int[10];
String[] nombre = new String[10];
String[] tipo = new String[10];
String[] hora_de_ingreso = new String[10];
String[] hora_de_salida = new String[10];
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
package proyecto_final;
import java.util.Scanner;
public class Informacion {
public void total() {
Scanner sc = new Scanner(System.in);
System.out.println("Nombres registrados: ");
System.out.println("Documento: ");
System.out.println("Tipo: ");
System.out.println("Hora de ingreso: ");
System.out.println("Hora de salida: ");
}
}
Los vectores de: "Nombre, Documento, Hora de ingreso Etc..." Los edité en la clase de "Registro" y esos valores los necesito pasar a la clase de "Información"
Gracias de atemano.
Valora esta pregunta
0