Pipes-SairagulAbd-KimberleyZell-Word-Guess.rb#5
Pipes-SairagulAbd-KimberleyZell-Word-Guess.rb#5kimpossible1 wants to merge 2 commits intoAda-C8:masterfrom
Conversation
Word-Guess GameWhat We're Looking For
Great work overall! I've noted a few places below where code could be better organized or streamlined, but in general I'm quite happy with what you've submitted. |
| def is_game_lost | ||
| if @bad_guesses >= 5 | ||
| return true | ||
| else |
There was a problem hiding this comment.
This method could be shortened to:
def is_game_lost
return @bad_guesses >= 5
end| @word = input_word.chars.to_a | ||
| @hidden_word = @word.join.gsub(/[A-Za-z]/, "_") | ||
| @bad_guesses = 0 | ||
| @word_descriptions = word_descriptions |
There was a problem hiding this comment.
I'm not sure I agree with calling this instance variable @word_descriptions. From the way it's used, it looks like it isn't a collection of descriptions, but a single description of the current word. @word_description (without the "s") might be a better choice.
|
|
||
| def word_descriptions | ||
| return "#{@word_descriptions}" | ||
| end |
There was a problem hiding this comment.
Since @word_descriptions is already a string, I think you could use attr_reader :word_descriptions with the same effect.
|
|
||
| def guess(letter) | ||
| if @word.include?(letter) == false | ||
| @bad_guesses += 1 |
There was a problem hiding this comment.
I really like that you make this its own method. It does one specific thing (handling a user's guess), and is just about the right amount of complexity to justify a method. Good work!
| while true | ||
| puts "***********" | ||
| g1.print_guessed_word | ||
| puts "***********" |
There was a problem hiding this comment.
The body of this loop might be a good candidate to turn into a method - something like take_turn. The code's already DRY, but it never hurts to put a label on things.
Word Guess
Congratulations! You're submitting your assignment.
Comprehension Questions