Conversation
Word-Guess GameWhat We're Looking For
Great work overall! I've got a few comments below, but overall I'm pretty happy with what you've turned in. Just make sure to watch your indentation better in the future. |
| @hidden_answer = @one_answer.gsub(/[a-z]/, '_') | ||
| @art =[ | ||
| " _ | ||
| \/\\ )\\ |
There was a problem hiding this comment.
This art takes up a large amount of space in your file, making it difficult to read. A good solution to this is to put it into another file, something like art.rb.
There was a problem hiding this comment.
That will also let you use Atom's auto-indent functionality without messing up your art.
|
|
||
| def guess_letter(guess) | ||
| guess_result = @answer.index(guess) | ||
| if guess_result == nil # negative result |
| require 'Faker' | ||
| class Game | ||
|
|
||
| def initialize |
There was a problem hiding this comment.
Instance methods should be indented within their class.
| @answer = Faker::Dessert.variety.downcase | ||
| no_spaces = @answer.delete(" ") | ||
| no_split = no_spaces.split("") | ||
| @one_answer = no_split.join(" ") |
| puts answer_array | ||
| matching_indices = answer_array.each_index.select {|i| answer_array[i] == guess } | ||
| matching_indices.each do |i| | ||
| replacement_letter = i |
There was a problem hiding this comment.
Good use of enumerables to solve this problem.
|
|
||
| def red | ||
| colorize(31) | ||
| end |
| puts "Start guessing!\n\n#{@art[0]}\n\n#{@hidden_answer}" | ||
| end | ||
|
|
||
| def guess_letter(guess) |
There was a problem hiding this comment.
I like that handling a guess is its own method, but it ends up being pretty complicated. Would it be possible to split it further into multiple small methods? Might make it easier to work with.
Word Guess
Congratulations! You're submitting your assignment.
Comprehension Questions