My question is how to make a kind of menu within another menu. For example, I display in my code 4 options to choose from, in one of them if it is chosen it would be necessary to also display several options to choose from. It would be like a nested menu. Below I leave my code:
import java.util.Scanner;
class Menu{
public static void main(String[] args){
int opciones;
Scanner leer = new Scanner(System.in);
Opcion1 op1=null;
Opcion2 op2=null;
Opcion3 op3=null;
Opcion4 op4=null;
System.out.println("Menu por consola");
System.out.println("1.- Registrar nuevo empleado");
System.out.println("2.- Obtener datos de contacto de un empleado");
System.out.println("3.- Listar todos los empleados que cumplan anios en cierta fecha");
System.out.println("4.- Obtener el presupuesto total");
System.out.println("Ingrese la accion a realizar: ") //Pretendo que el usuario escriba el numero de opcion
opciones=leer.nexInt();
switch(opciones) {
case 1:
op1=new Opcion1();
op1.registrarNuevoEmpleado();
break;
case 2:
op2=new Opcion2();
op2.obtenerDatos();
String variable = op1.variableOpcion1;
break;
case 3:
op3=new Opcion3();
op3.listarEmpleadosCumpleaños();
break;
case 4:
op4=new Opcion4();
op4.presupuestoPorArea();
break;
default:
System.out.println ("Numero no valido");
}
}
}