This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: May 11, 2005
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...
Joined: Jan 29, 2003
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.