Skip to content

Cara Brennan & Anne Watson - Octos - Word Guess#8

Open
MississippiBrenn wants to merge 1 commit intoAda-C9:masterfrom
MississippiBrenn:master
Open

Cara Brennan & Anne Watson - Octos - Word Guess#8
MississippiBrenn wants to merge 1 commit intoAda-C9:masterfrom
MississippiBrenn:master

Conversation

@MississippiBrenn
Copy link

@MississippiBrenn MississippiBrenn commented Feb 14, 2018

Word Guess

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
How do you feel you and your partner did in sharing responsibilities? Definitely a learning process but we can see the benefits
For each partner what parts of the project did you find challenging? Cara: holding back and being patient. Anne: not jumping from thing to thing
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? Did initialize method in GameData class that held our picture we were rendering as well as our variables to generate from Faker (pokemon and rick & morty quotes
Describe an instance where you used a local variable instead of an instance variable. Why did you make that choice? We used split_word in our display_word method that we used to loop. We didn't need to use it outside of the method so we went local
What code, if any, did you feel like you were duplicating more than necessary? Not really
Is there a specific piece of code you'd like feedback on? Getting spaces in our Rick & Morty quote would be nice

@droberts-sea
Copy link

Word-Guess Game

What We're Looking For

Feature Feedback
Baseline
Regular Commits with meaningful commit messages. N/A - looks like you used the old copy/paste method to submit instead of git push, so I cannot see your commit history
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. some - see inline
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. yes

Great job overall! There are a couple of places where the structure of this code could be improved (see inline comments below), but in general your code is clean and readable, and I feel you've definitely hit the learning goals for this assignment. Keep up the hard work!

end
print "#{@change_split_word.join}\n"
if @change_split_word.include?("_")
user_input

Choose a reason for hiding this comment

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

Here, user_input calls guess, which calls display_word, which in turn calls user_input again. this is an example of a programming technique called recursion, which you'll learn about in CS Fun in a few months.

Recursion is a powerful tool that can elegantly solve many problems. However, in this case I think a while loop might be a better choice, if only because it makes it immediately obvious to the reader that this code might execute many times. Something like:

def run_game
  while @change_split_word.include?("_") && @bad_array.length < 5
    user_input
    guess
    display_anchor
    display_word
  end
  # ... figure out if the user won or lost, and tell them
end

# input
def user_input
puts 'Choose a letter please'
@user_choice = gets.chomp.downcase

Choose a reason for hiding this comment

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

I don't know that I agree with the decision to make @user_choice an instance variable. This value is transient, since it will change whenever the user makes another guess, and this is usually a good indicator that an instance variable is not the right choice.

Instead, you could store the letter as a local variable, and pass it to guess as a parameter.

# guess
def guess
if @word.include?(@user_choice)
print "Good guess that letter is in the word!\n"

Choose a reason for hiding this comment

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

You've done a very good job of functional decomposition here - each function has one clear job, and they're neither too big nor too small.

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