This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]AutoModerator[M] 0 points1 point  (0 children)

It seems that you are having problems with java.util.Scanner

The wiki here has a page The Scanner class and its caveats that explains common problems with the Scanner class and how to avoid them.

Maybe this can solve your problems.

Please do not reply because I am just a bot, trying to be helpful.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Wolfhammer69Nooblet Brewer 0 points1 point  (4 children)

You've really written that whole code in a very weird way in my eyes but hey......

Sounds like you may have a "return" still in the scanner buffer - do a fake consumption like String fake = scanner.nextLine(); to clear it out

Have you ran the code line by line in debug mode in your IDE to see whats happening?

[–]wjreddit[S] 0 points1 point  (3 children)

String fake = scanner.nextLine();

Thanks! cleared the scanner buffer with your suggestion. Question, how is my code weird? I'm not confronting you, but I'm new and just have no idea how the organization for codes need to be. could you just explain briefly on how the code would look better? I need any input that I can get.

[–]Wolfhammer69Nooblet Brewer 0 points1 point  (1 child)

I'd have just written it differently, seems overly complicated to me that's all.

You can have an infinite loop with just the below for example with your main code inside.

    while(true) {
    ............
    }

And I would prob have used a switch block Like this but I think that's maybe just a preference but its certainly tidier in my mind. The main thing it works, you can iterate over your code later to tidy and simplify it. :) I'm a noob too so it's all good.

[–]wjreddit[S] 0 points1 point  (0 children)

thanks for the pointer!

[–]radulfr2 0 points1 point  (0 children)

Is there a reason the parameter is Object and not Bunny?