Skip to content

Pipes-SairagulAbd-KimberleyZell-Word-Guess.rb#5

Open
kimpossible1 wants to merge 2 commits intoAda-C8:masterfrom
kimpossible1:master
Open

Pipes-SairagulAbd-KimberleyZell-Word-Guess.rb#5
kimpossible1 wants to merge 2 commits intoAda-C8:masterfrom
kimpossible1:master

Conversation

@kimpossible1
Copy link

Word Guess

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
How do you feel you and your partner did in sharing responsibilities? Good
Describe an instance where you used a method for something to encapsulate the functionality within your class. What does it do? What are its inputs and outputs? We used guess method to take the user's input of letter guess and check if the letter is in the word, and then also check the word again for the letter until it finds all occurrences of the letter guessed. It also enters that letter into the correct space/index of the word output the user sees by updating the "hidden word."
Describe an instance where you used a local variable instead of an instance variable. Why did you make that choice? We used a local variable "rand_num" to generate a random number, because we only use it once in the program, at the beginning of the program, to determine which word will be used.
What code, if any, did you feel like you were duplicating more than necessary? We used a separate variable for the original word chosen and for the output to the user. It may be possible to use the same variable for both, but we did not find a way.
Is there a specific piece of code you'd like feedback on? NA

@droberts-sea
Copy link

Word-Guess Game

What We're Looking For

Feature Feedback
Baseline
Regular Commits with meaningful commit messages. no - You only have two commits! It's important to make good git hygiene part of your workflow now, because it'll be much harder to work it in later on. If you're struggling to break out of the zone and remember to commit, this article might be interesting to you.
Readable code with consistent indentation. yes
Answered comprehension questions yes
Product Functionalities
Created a Class to encapsulate game functionality. yes
Used methods to DRY up your code. yes
Created instance variables & local variables where appropriate. yes
Used Arrays to store lists of letters guessed. yes
Used variables & random numbers to allow the game to function with multiple words, no hard-coded answers. yes
Programmed "defensively" to detect errors in user input. I was able to input the same letter twice, an entire word, and special characters - all registered as an incorrect guess.

Great work overall! I've noted a few places below where code could be better organized or streamlined, but in general I'm quite happy with what you've submitted.

def is_game_lost
if @bad_guesses >= 5
return true
else

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method could be shortened to:

def is_game_lost
  return @bad_guesses >= 5
end

@word = input_word.chars.to_a
@hidden_word = @word.join.gsub(/[A-Za-z]/, "_")
@bad_guesses = 0
@word_descriptions = word_descriptions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree with calling this instance variable @word_descriptions. From the way it's used, it looks like it isn't a collection of descriptions, but a single description of the current word. @word_description (without the "s") might be a better choice.


def word_descriptions
return "#{@word_descriptions}"
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since @word_descriptions is already a string, I think you could use attr_reader :word_descriptions with the same effect.


def guess(letter)
if @word.include?(letter) == false
@bad_guesses += 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like that you make this its own method. It does one specific thing (handling a user's guess), and is just about the right amount of complexity to justify a method. Good work!

while true
puts "***********"
g1.print_guessed_word
puts "***********"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of this loop might be a good candidate to turn into a method - something like take_turn. The code's already DRY, but it never hurts to put a label on things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants