Nombre: Menu and submenu Reading from the command line with J2SE and windows command interpreter
Descripción:
Menu and submenu Reading from the command line with J2SE and windows command interpreter
URL: http://www.mygnet.net/codigos/j2se/menus/menu_and_submenu_reading_from_the_command_line_with_j2se_and_windows_command_interpreter.2727
Código Fuente:
/*
Author: Gerardo Angeles Nava
Objective: Menu and submenu Reading from the command line with J2SE and windows command interpreter
Note: To exit the program press [Ctrl]+[c]
*/
import java.io.*;
class MenuCmd{
void Author(){
System.out.print("nnttThanks for trying, July 2008 - Gerardo Angeles Nava, Mexico, D.F.nn");
}
void MainOptionA(){
this.SubMenu1();
}
void MainOptionB(){
System.out.print("nttselect main option Bn");
}
void MainOptionC(){
System.out.print("nttselect main option Cn");
}
void SubMenu1(){
System.out.print("nt.===============.================.===============.===============.n");
System.out.print("nt| Option 1 [a] | Option 2 [b] | Option 3 [c] | Exit [e] |n");
System.out.print("nt`===============`================`===============`===============`n");
while(true){
try {
System.out.print("ntSub Option A1: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
if(s == null){
this.Author();
System.exit(1);
}
//If BufferedReader can not convert to int, assign an invalid option like zero for example.
try{
int iTmp = Integer.parseInt(s);
s = "