java return to specific point in program -


i have next question. have program has structure:

loadcontext(); showcategories(input); showprojects(input); showdetails(); 

on each step me user has ability jump previous step. example press 0 , program returns previos step. press 1 - program starts beginning. there instruments in java come specific point?

edit: have here console application. main method looks like:

loadcontext();//loads categories showcategories(input);//shows available categories , ask category show showprojects(input);// shows projects inside selested category , select project show in details showdetails();//show selected project 

now want set option. example, in showprojects(input) put 0 , see again categories, select , see category. in showdetails() select 0 , show categories, select 1 , on.

you can this:

  1. wrap 4 methods in method:

       private void programstart(){        loadcontext();        showcategories(input);        showprojects(input);        showdetails();    } 
  2. then have method this:

       private void processuserinput(int seloption) {        if(seloption == 0){            showcategories();        }        else if(seloption == 1){            programstart();        }        else{           system.out.println("unsupported option");                          }    }   
  3. at end of each of methods want have option available:

    a. read option users
    b. call processuserinput(input) input


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -