Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2004

Tip: Looking for answers? Try searching our database.

simple textIO question

Thread view: 
zcraven - 02 Nov 2004 20:03 GMT
I have made a command prompt text based menu interface.  It is a 'league
menu' that displays 10 options and you type '2' or whatever and it then does
something (e.g. display a list of teams).  It works fine, except I want to
have a sub-menu ('Club Menu') that also has a list of 10 options.  I can get
it to display this club menu, but when you type any number at that point it
just returns to the league menu again.

I think the problem is with this piece of code:

public static void main (String[] args)
   {
       MainProgram testdata = new MainProgram();
       testdata.createLEAGUEPremiership();
       System.out.println("");
       System.out.println("**TEST DATA HAS BEEN GENERATED**");
       System.out.println("");
       int selector =0;
       do
       {
       selector = testdata.leagueMenu();
       testdata.leagueProcessSelector(selector);
       }
       while (selector != 666);
   }

Do I need another one of these do/while - 'selector' bits of code lower down
in the leagueMenu method?

This is the code for the leagueMenu, though I dont know if you need it.  The
other methods are very long but I can add them on request.

public int leagueMenu() // throws IOException
   {
       System.out.println("");
       System.out.println("LEAGUE MENU (" + L1.getLeagueName() + ")");
       System.out.println("=====================");
       System.out.println("1. View league table");
       System.out.println("2. Change League name");
       System.out.println("3. Add a new club");
       System.out.println("4. Delete a club");
       System.out.println("5. Generate fixture list");
       System.out.println("6. Record a result");
       System.out.println("7. View current top scorer(s)");
       System.out.println("9. CLUB MENU (Update/View an existing club)");
       System.out.println("666. -- Exit Program --"); //this doesnt work
       System.out.println("Select option: ");
    try {
       BufferedReader keyboardInput = new BufferedReader(new
InputStreamReader(System.in));
       System.out.println("");
       return Integer.parseInt(keyboardInput.readLine());
   } catch (Exception e) {
       System.err.println(e.getMessage());
   }
   return 0;
   }
Hal Rosser - 05 Nov 2004 02:52 GMT
for 'nested' command-line menus, use nested while loops


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.