Results 1 to 5 of 5
  1. #1

    Help with Hangman like code

    Hey all,

    I am learning Ruby and I am struggling to fix the issue with the program i am playing with. I cant get it to end after the correct number of misses and i also cant seem to get it to properly enter in the letter when i correctly guess. I spend hours tooling with it, any help or suggestions?

  2. #2

    Help with Hangman like code

    word_bank = %w[venezuela peru colombia brazil argentina chile uruguay]


    puts "\nWelcome to Hangman Lite!"

    play_again = TRUE

  3. #3

    Help with Hangman like code

    progress_word = Array.new(target_letters.size, '-')
    # reset counter to ten bad guesses permitted
    attempt_count = 10

  4. #4

    Help with Hangman like code

    if target_word.include?guess
    for x in (0..target_word.size - 1)
    # if letter was already guessed, do not count it again
    if target_letters[x] == guess and progress_word[x] == "_"
    progress_word[x] = guess
    remain_count - 1
    end
    end

  5. #5

    Help with Hangman like code

    if remain_count == 0
    puts "\n\nCongratulations, you guessed the word!"
    else
    puts "\n\nSorry, you ran out of attempts."
    end
    # show the word
    puts "\nThe word is... #{target_word} "
    # take the word from the last game out of play
    word_bank.delete_if { |word| word == target_word }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •