-
Notifications
You must be signed in to change notification settings - Fork 27
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
Word Guess - Brandy and Angela - Octos #9
base: master
Are you sure you want to change the base?
Conversation
Word-Guess GameWhat We're Looking For
|
# start body | ||
|
||
# intro | ||
puts "Welcome to Val's Word Guess!\n\n".colorize |
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 is a bug? Did you test it?
def user_choose_letter | ||
puts "\n\nChoose a letter: " | ||
user_guess = gets.chomp | ||
until user_guess =~ /^[a-zA-Z]$/ |
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 suggest also testing to make sure the user hasn't guessed that letter yet.
end | ||
|
||
def create_underscores | ||
word_length = @word.instance_variable_get(:@word_array).length |
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.
If you're going to get the word's word_array
instance variable, use an attr_reader
in the Word
class. In general, never use instance_variable_get
. That bypasses the public interface of the class.
Also you're never using word_length
@guess_status = [] | ||
end | ||
|
||
def update_guess_counter(true_false) |
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.
What is true_false
supposed to represent. This isn't a great variable name.
end | ||
|
||
def update_guess_counter(true_false) | ||
@guess_counter -= 1 if true_false == false |
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.
Instead of true_false == false
You can just do if !true_false
|
||
game.print_ascii_art | ||
puts "\n" | ||
underscores = game.create_underscores |
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.
You could move game.create_underscores
to before the loop starts, and then you wouldn't need the if
statement at all, both blocks could be merged.
Word Guess
Congratulations! You're submitting your assignment.
Comprehension Questions