Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create a console menu using a class.

 
Pete Tyo
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to find out if there is a class that is already made I can use to create a console menu and receive input. I have been looking around and only thing I can find is class Gmenu which is for gui as far as I can tell. Does this class exist or should I attempt to create it myself?

Thanks,

Pete
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're going to do a number of interactive console apps, say for school, it would be a neat exercise to make your own. With no thought for how it works, what would you like it to do? Maybe:

Given an array of strings for a menu, display the menu, accept user input, return the index of the menu item chosen. If the user enters invalid data, say a number out of range or the word "bob", issue an error message and redisplay the menu.

Given a descriptive prompt, display the prompt and accept input from the user.

Given a descriptive prompt, a max and a min display the prompt and accept a number in the specified range from the user.

Back in my mainframe days I had many interactive console apps and a whole library of prompting routines with fairly sophisticated validation. All the prompts need a way to bail out - like "quit" or something.
 
Pete Tyo
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like it to do pretty much what you said. This is my first Java class so I am a little slow at getting the code out. I have the general concept of what I want down, now just figuring out how to code it...

Pete
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. Try a tiny bit, post it if you get stuck.

Keep it fun! Set very small goals, write a few lines of code, make it work, eat one M&M. It's a lot more rewarding (and productive and bug free) to have little successes every few minutes than to slave over a hundred lines of code all night and find it doesn't work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic