Search:

Type: Posts; User: tonynsx

Search: Search took 0.10 seconds.

  1. Re: Java hangman help with comparing array to String

    I'm sorry, but I don't know much about when and when not to use boolean. This is what I have so far


    package test;

    import java.util.Scanner;
    import java.util.Random;

    public class Test {
  2. Re: Java hangman help with comparing array to String

    I'm trying to count the number of times the user guesses the wrong character

    Yes, the count should be incremented by 1 anytime the user guesses the wrong character

    How can I implement the...
  3. Re: Java hangman help with comparing array to String

    With out those two lines, my guess won't show up in the dash[]. It will display just -------
    I removed the second line, dash[word.indexOf(guess.charAt(0))] = check;, and it still works, so I guess...
  4. Re: Java hangman help with comparing array to String

    Solved

    Java Platform SE 7

    Here's the working code, what I did was, I converted the char dash[] into a new String (test), and just compared two string with .equals(). Now time to work on the...
  5. Re: Java hangman help with comparing array to String

    Sir, thanks for your help so far. I have to go to class now, so I'll let you know if I figure something out.

    Tony
  6. Re: Java hangman help with comparing array to String

    I've made some modification.


    if(word.charAt(b) == dash[b])// currently working on this, make an array to store guesses?
    {
    // dash[b] =...
  7. Re: Java hangman help with comparing array to String

    I did look, but I can't figure out what's going on.

    --- Update ---

    I have Java class tomorrow, and I'll ask my professor to look at my code if I can't figure it out.
  8. Re: Java hangman help with comparing array to String

    What I meant was, moving the if condition outside of the for loop did the same thing.

    No sir, I'm sorry. I still have the original problem.
  9. Re: Java hangman help with comparing array to String

    So what should I do to fix it?

    I don't understand what I'm doing wrong. Logically, I'm comparing each index of dash[] with word.charAt(b), so it should work.

    --- Update ---



    I've put...
  10. Re: Java hangman help with comparing array to String

    This is the code with compiler error:


    package test;

    import java.util.Arrays;
    import java.util.Scanner;
    import java.util.Random;

    public class Test {
  11. Re: Java hangman help with comparing array to String

    dashArray[b] == (word.charAt(b) I tried to do it like that, but it's giving me a syntax error, so I can't compile it.

    " " + dashArray[b] == ("" + word.charAt(b) I tried this way, compiles but,...
  12. Re: Java hangman help with comparing array to String

    I did a system.out to see the actual values each time, and as you can see, even when dash[b] = elephant, and the word.charAt(b) matches it, it's still waiting for me to enter something instead of...
  13. Java hangman help with comparing array to String

    I'm trying to figure out how to let the dash[] know the player entered all the correct letters to solve the game. It knows the correct word was guessed, the first part of the if condition...
Results 1 to 13 of 13