PDA

View Full Version : Java-Help with user response


Kura_kai
04-16-2005, 02:21 AM
I am working on a project and i am having troubles. It is a 9 file project and it interlinks and stuff. The only problem is that when the user decides to enter the number 1 which should run a method in another file and stops to wait for them to press enter before going back to the menu. That works but the part that messes up is that after that get back to the menu it doesn't want to accept numbers for sometime. For example it should go:
1. Display Menu
2. User Input Choice
3. Goes to method they selected
4. Wait for them to type in anything then enter
5. Go back to step 1
But not it goes back to the start but skips to step 5 for some time.
If anyone needs me to post the files i will in a zipped file so that it becomes easyer for someone to have access to all files.

tricolaire
04-17-2005, 07:33 AM
it woudl deffinately help if you posted the files.

I had the same issue in an application, and I believe it had somethign to do with flushing the input buffer, but in this case I woudl need the code

-Moi

Kura_kai
04-18-2005, 12:30 AM
Here it is all the files or something like that the error happens all over the place.

tricolaire
04-18-2005, 01:59 AM
here is what I would try:

in the class contained in Robots.java, instead of getting your input through System.in.read(), use the classes you imported from java.io

private static BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));

then use the BufferedReader method readLine() to grab input.

tell me if it works.

Kura_kai
04-18-2005, 02:04 AM
I am sorry but this is a project for school and our stupid teacher wont let us do anything fancy like that. Is there another way you know if possible?

tricolaire
04-21-2005, 03:56 AM
give me a few days to look over it.

but in my expirience, it might be worth it to just to say nuts to the teacher and do somethign fancy anyway.

Kura_kai
04-22-2005, 01:03 AM
ha ha ha i really want to since she is learning java to and i know more than her about it. What i figured out today is that if they type in something it works fine but whenever i just want to have them just push enter it messes up. Though i prefer actualy to push enter but when you do it goes down a line and waits again and you press enter again or anything that time it starts screwing up.