Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ejercicio_6_poo;
- /**
- *
- * @author david
- */
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- public class Ejecutable {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner leer = new Scanner(System.in);
- String a[] = {"asd", "dfg"};
- List almacen = Arrays.asList(a);
- int no_empleados;
- String nombre;
- int eleccion2 = 0;
- System.out.println("Ingrese la cantidad de empleados que desea registrar");
- no_empleados = leer.nextInt();
- Empleado listaEmpleados[] = new Empleado[no_empleados];
- for (int i=0; i<listaEmpleados.length; i++){
- System.out.println("¿Rango principal?\n1. Directivo \t 2. Operario");
- int eleccion;
- eleccion = leer.nextInt();
- if (eleccion < 1 || eleccion > 2){
- System.err.println("Ingrese un valor válido, apagando programa.");
- return;
- }
- switch (eleccion){
- case 1:
- System.out.println("Ingrese el nombre del empleado");
- nombre = leer.next();
- listaEmpleados[i] = new Directivo(nombre);
- List lista = Arrays.asList(listaEmpleados);
- almacen = lista;
- break;
- case 2:
- System.out.println("Ingrese el nombre del empleado");
- nombre = leer.next();
- listaEmpleados[i] = new Operario(nombre);
- lista = Arrays.asList(listaEmpleados);
- almacen = lista;
- System.out.println("Rango secundario: \n1.Oficial \t2.Tecnico");
- eleccion2 = leer.nextInt();
- if (eleccion2 < 1 || eleccion2 >2 ){
- System.err.println("Ingrese un valor válido, apagando programa.");
- return;
- }
- switch(eleccion2){
- case 1:
- listaEmpleados[i] = new Oficial(nombre);
- break;
- case 2:
- listaEmpleados[i] = new Tecnico(nombre);
- break;
- }
- break;
- }
- }
- System.out.println(almacen.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement