r/learnjava • • Jul 06 '15

Can anyone tell me what's wrong with this code?

Post image
0 Upvotes

10 comments sorted by

3

u/CSResumeReviewPlease Jul 06 '15

What isn't it doing correctly?

1

u/[deleted] Jul 07 '15

Here's the class.

Here's the test program.

Here's what it should print out.

But...here's what mine prints out.

3

u/sfmqur Jul 06 '15

Can you post the whole class? It would make it easier to find errors.

1

u/[deleted] Jul 07 '15

Here's the class.

Here's the test program.

Here's what it should print out.

But...here's what mine prints out.

2

u/Pvt_Haggard_610 Jul 06 '15

Any errors?

1

u/[deleted] Jul 06 '15

I'm going to get back to you guys tomorrow when I have more time. I'll explain it all much clearer. Thank you so much for your time.

1

u/[deleted] Jul 07 '15

Here's the class.

Here's the test program.

Here's what it should print out.

But...here's what mine prints out.

2

u/BadBoy6767 Jul 06 '15

Yes, a full class or the full project would be very helpful. Any errors, too?

1

u/[deleted] Jul 07 '15

Here's the class.

Here's the test program.

Here's what it should print out.

But...here's what mine prints out.

1

u/AkrioX Jul 09 '15

If I read the code correctly this is like a hangman game, you should assign a new value for the x in the loop like

x = "" + this.word.charAt(i++);

If you don't progress with the x, your program will only check the first letter obviously.