Skip to content

<Pipes>-<Roxanne Agerone>-<Word-Guess>#11

Open
RAgerone wants to merge 7 commits intoAda-C8:masterfrom
RAgerone:master
Open

<Pipes>-<Roxanne Agerone>-<Word-Guess>#11
RAgerone wants to merge 7 commits intoAda-C8:masterfrom
RAgerone:master

Conversation

@RAgerone
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? I think it turned out rather well. We worked in our free time to finish the project.
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? I used a method to create a hidden word. It takes the amount of letters and puts a blank array to display.
Describe an instance where you used a local variable instead of an instance variable. Why did you make that choice? I used a local variable for word index. It is only necessary to call the variable within the definition and not without.
What code, if any, did you feel like you were duplicating more than necessary? I used a lot of Mona Lisa strings, but I like them, so it's fine.
Is there a specific piece of code you'd like feedback on? Not right this second, but if there's any functionality that you think that could be improved upon or made simpler, I'd love to hear about it

@droberts-sea
Copy link

Word-Guess Game

What We're Looking For

Feature Feedback
Baseline
Regular Commits with meaningful commit messages. yes
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. mostly - I was able to type in more than one letter and it counted it as a wrong guess.

Great work overall! I've pointed out a few places where you might be able to restructure your code to make it cleaner, but overall I'm quite happy with what you've submitted.

puts win.asciify(@word).colorize(:cyan)
when @fails == 1
puts " one wrong
o8%8888,

Choose a reason for hiding this comment

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

I like your ascii art, but having all this text in the middle of your program makes it hard to read and to work with. Would it be possible to move this data to a separate file, perhaps something like art.rb?


def choose_word(dictionary)
@word = dictionary.sample.upcase
end

Choose a reason for hiding this comment

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

I like that you've made this its own method. However, the way your code is currently structured it's possible to create an instance of Hangman without calling choose_word, in which case none of the rest of your code would work.

A cleaner approach might be to call choose_word directly from initialize, so that it's guaranteed to always happen. This would make your code just a little bit harder to use incorrectly.


case
when !!(letter_guess =~ /[A-Z]/) && !@guesses.include?(letter_guess)
@guesses << letter_guess

Choose a reason for hiding this comment

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

I'm curious why you choose a case statement for this outer check. Since there's only two options (good guess / bad guess), it seems to me that an if statement might be a little easier to read.


def pick_a_letter

while @word.split("") != @hidden_word

Choose a reason for hiding this comment

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

I like that pick_a_letter is its own method!

However, this method ends up being pretty big and complex, even if you don't count the ASCII art. Would it be possible to break it up further? For example, you could have a get_user_guess method that asks the user for a letter and verifies it's valid.

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