Search:

Type: Posts; User: dataghost

Page 1 of 2 1 2

Search: Search took 0.18 seconds.

  1. Replies
    1
    Views
    611

    Help Passing Variables

    Based on the method descriptions below, how can I pass the Scanner from the main() method to the promptUserForSeed() method, and how can I use the long variable that the promptUserForSeed() method...
  2. Replies
    2
    Views
    757

    Re: Word Search Program Help

    I think I've implemented the highlightWord() method correctly, I just need help now with passing the long variable "seed" from the promptUserForSeed() method into the findWords() method, and then...
  3. Replies
    2
    Views
    757

    Word Search Program Help

    I'm having trouble with a WordSearch project that I've been assigned.

    Essentially, what I'm supposed to do is create a Java program that reads a word search grid from a class that has been written...
  4. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    I've actually solved the problem of delayed print statements. A problem I have now is printing both characters in a string if said string happens to contain two identical characters, like character...
  5. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Thank you, I have displayWord storing old guesses as well as new ones, but when it prints displayWord after new guesses it is delaying the reveal of said guesses by one round.

    This is the code I...
  6. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Could you explain to me how this code would update if I was entering a new number every time it ran? In that case '3' would have to be a variable to account for the user's input.

    EDIT: Never mind,...
  7. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    I completely forgot to place quotes around the digit in order to define it as a string. With that correction the code now works. I've applied this logic to my hangman code and I no longer recieve...
  8. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Here is the code I tried for the indexOf method:

    public class Tests
    {
    public static void main(String[] args)
    {
    String str = "01234";

    String substringOne = str.substring(0,...
  9. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    If I replace the for loop with secretWord.indexOf(guess), I lose the use of int variable index for determining where guess should appear in displayWord. How do I print displayWord with the correct...
  10. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Thank you, that makes sense. I had them mislabeled in my head. So, you're asking me why I use this loop at all? I use it to loop through the length of secretWord until it matches the character at...
  11. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Which loop do you mean?

    if(secretWord.charAt(guess) == guess.charAt(0)) or

    for(int index = 0; index < secretWord.length(); index++) or

    if(secretWord.indexOf(guess) >= 0)

    If you are...
  12. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    What do you mean when you say "just use the value returned by the indexOf method"?

    I fixed the practice problem and it prints correctly now:

    String str = "01234";
    String updatedStr = "";...
  13. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    (The word is: -----) What is encapsulated in the parentheses is from displayWord.

    Here's what I have to replace "3" with X:

    String str = "01234";
    String updatedStr = "";
    for(int index = 0;...
  14. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    updatedDisplayWord holds substringOne (the number of dashes in displayWord from 0 to index) + the guessed letter + substringTwo (the number of dashes from index to the end of displayWord)

    This is...
  15. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    I'm not sure how I can get updatedDisplayWord to update every round of the game while also holding the value of the rounds before it, I need some help in figuring it out. When I don't add displayWord...
  16. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    I was trying to think of some way to store the updated string every round, I'm not quite sure how to go about this. Also, I added displayWord += "-"; because when this line isn't added in the for...
  17. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    The lines:

    for (int index = 0; index < secretWord.length(); index++) //Loop over secretWord
    {

    displayWord += "-";
    if (secretWord.indexOf(guess) == index) //If indices match
    {...
  18. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Yes, I'm talking about substringTwo = displayWord.substring(index). The value of displayWord is ----, the value of index changes as it loops through the length of secretWord (starting at 0, and then...
  19. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Here are new debug print statements:
    The secret word is: Java
    The word is: ----
    Enter the number of spaces allowed: 4
    Enter the letter you want to guess: v

    Your guess is in the word!
    ...
  20. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Here are some print statements for relevant variables:

    VARIABLE OUTPUTS FOR DEBUGGING PURPOSES ONLY
    Value of secretWord: algorithms
    Value of displayWord: -----------
    Value of index at end of...
  21. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    I have used paper and pencil, but I'm still struggling with the logic behind it I suppose. In my new code, the problem is my substringTwo variable. It isn't printing out the correct number of dashes...
  22. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    Thank you! That makes a lot of sense, I overlooked that. I changed to a substring method in the for loop over displayWord because I thought it would help more, and I think I've made a bit of...
  23. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    This snippet of code...

    for(int index = 0; index < secretWord.length(); index++)
    {
    displayWord = "-";
    System.out.print(displayWord);
    }

    ...prints out the correct number of dashes...
  24. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    This is what I'm trying to figure out. I tried splitting it into substrings, like this:


    System.out.print("Enter your guess: ");
    String guess = input.next().substring(0, 1);

    for(int index =...
  25. Re: Help with Simple Text-Based Hangman Game (No Arrays or Object-Oriented Programming)

    displayWord is supposed to be the "hidden" version of the secret word that is generated randomly. It is displayed as a series of dashes that is equal in length to the secret word. I set up a for loop...
Results 1 to 25 of 29
Page 1 of 2 1 2