<Pipes>-<Roxanne Agerone>-<Word-Guess>#11
Conversation
Word-Guess GameWhat We're Looking For
Great work overall! I've pointed out a few places where you might be able to restructure your code to make it cleaner, but overall I'm quite happy with what you've submitted. |
| puts win.asciify(@word).colorize(:cyan) | ||
| when @fails == 1 | ||
| puts " one wrong | ||
| o8%8888, |
There was a problem hiding this comment.
I like your ascii art, but having all this text in the middle of your program makes it hard to read and to work with. Would it be possible to move this data to a separate file, perhaps something like art.rb?
|
|
||
| def choose_word(dictionary) | ||
| @word = dictionary.sample.upcase | ||
| end |
There was a problem hiding this comment.
I like that you've made this its own method. However, the way your code is currently structured it's possible to create an instance of Hangman without calling choose_word, in which case none of the rest of your code would work.
A cleaner approach might be to call choose_word directly from initialize, so that it's guaranteed to always happen. This would make your code just a little bit harder to use incorrectly.
|
|
||
| case | ||
| when !!(letter_guess =~ /[A-Z]/) && !@guesses.include?(letter_guess) | ||
| @guesses << letter_guess |
There was a problem hiding this comment.
I'm curious why you choose a case statement for this outer check. Since there's only two options (good guess / bad guess), it seems to me that an if statement might be a little easier to read.
|
|
||
| def pick_a_letter | ||
|
|
||
| while @word.split("") != @hidden_word |
There was a problem hiding this comment.
I like that pick_a_letter is its own method!
However, this method ends up being pretty big and complex, even if you don't count the ASCII art. Would it be possible to break it up further? For example, you could have a get_user_guess method that asks the user for a letter and verifies it's valid.
Word Guess
Congratulations! You're submitting your assignment.
Comprehension Questions