-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipes - Salome & Kee - Word Guess #24
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch indentation here.
require 'Faker' | ||
class Game | ||
|
||
def initialize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your word selection!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of enumerables to solve this problem.
|
||
def red | ||
colorize(31) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these methods used?
puts "Start guessing!\n\n#{@art[0]}\n\n#{@hidden_answer}" | ||
end | ||
|
||
def guess_letter(guess) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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