-
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
Samantha Berk & Winifred Irarrazaval - Word-Guess - Octos #15
base: master
Are you sure you want to change the base?
Conversation
…ariable to compare user inputs to secret word.
…using .index() and moved user input outside of the class
…aned up user interface
… if they re-typed a letter
Word-Guess GameWhat We're Looking For
Great job overall! I especially appreciate the organization of having all the art logic live in a separate class - this makes your |
@@ -0,0 +1,171 @@ | |||
require '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 file should be named word_guess.rb
. Without the suffix, GitHub doesn't know to syntax highlight it!
print_strings | ||
end | ||
def remove2 | ||
@parachute_strings[-1] = " " |
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're right that this code is duplicated, but it's also a tricky thing to figure out how to print only what you want. What if you modified the print_strings
method to take a number of lives remaining - something like this:
def print_strings(lives_left)
# strings before the center strap
(0...2).each do |i|
if i <= lives_left
print @parachute_strings[i].colorize(:magenta)
else
print " " * @parachute_strings[i].length
end
end
# center strap
print @parachute_strings[2]
# strings after the strap
(3...5).each do |i|
if i <= lives_left
print @parachute_strings[i].colorize(:magenta)
else
print " " * @parachute_strings[i].length
end
end
end
The center strap makes the whole thing much more complex - maybe it would be best to just take it out.
case @life | ||
when 4 | ||
@picture.remove1 | ||
when 3 |
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 we made the above change, here we would replace this entire case statement with:
@picture.print_strings(@life)
|
||
parachute_man = Picture.new() | ||
new_game = Game.new(word_list.sample.split(""), parachute_man, parachute_man.life ) | ||
puts |
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.
Since the initial life count comes from the picture, it's a little redundant to pass both into the constructor here.
Word Guess
Congratulations! You're submitting your assignment.
Comprehension Questions