Skip to content
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

Dikla and Brenda - Word_Guess - Octos #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

brendarios
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? very good, we share ideas respecfully the whole time
For each partner what parts of the project did you find challenging? for Brenda it was challenging to fill the underscore with the letter and for Dikla to use the ascii art
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? the method of selection of level was used to determine the level of the game. it inputs the level the user wants and outputs the array of words to be used based on the level.
Describe an instance where you used a local variable instead of an instance variable. Why did you make that choice? the local variable letter because it chances according to the user input.
What code, if any, did you feel like you were duplicating more than necessary? the ascii images method
Is there a specific piece of code you'd like feedback on? not anything in specific

@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. mostly - 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

Good job overall! There's definitely some places where this code could be cleaned up, but in general this is a solid submission that meets the learning goals for this assignment. Let me know about questions on any of my comments below, and keep up the hard work!


attempt = 0
while !levels.include?(level)
if attempt < 3

Choose a reason for hiding this comment

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

I think that this loop within a loop is more complicated that it needs to be. We could simplify things as follows:

def selection_level
  valid_levels = %w(low medium high)
  level = nil
  attempts = 0
  until valid_levels.include?(level) || attempts > 3
    puts "Please enter a level: low, medium or high?"
    level = gets.chomp.downcase
    attempts += 1
  end

  if valid_levels.include?(level)
    if level == "low"
      @word_array = @words_low
    elsif level == "medium"
      @word_array = @words_medium
    else
      @word_array = @words_high
    end
  else
    puts "Too many attempts..start the program again"
    exit
  end
end


# This conditional checks in case the user enters the whole word
if letter.length > 1
if letter == @word

Choose a reason for hiding this comment

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

Comments should be indented the same as the rest of your code.

#This loop helps the user to don't be penalized for guessing the same letter more than once.
while @letters_guessed.include? letter do
puts "You have already tried this letter, try another one: "
letter = gets.chomp

Choose a reason for hiding this comment

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

It might make sense to add this loop to the validate_input_letter function.

end
if @word.split(//) == @letters_correct
you_win
exit

Choose a reason for hiding this comment

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

There are several places in your code where you exit. This is fine for this assignment, but it means your program is limited to only playing the game once. An interesting exercise is to think about how you would have to change it for the user to be able to play again.

# We did this to don't count inputs as wrong guesses if the user inputs numbers, symbols etc.
def validate_input_letter(input)
until !input.match(/[^a-z]/)
puts "\nPlease return a valid letters from A to Z.\n"

Choose a reason for hiding this comment

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

This loop conditional is a little confusing, since you have three negations: until (backwards while), the !, and the ^ in the regex.

Instead, you might say while input.match(/[^a-z]/).

def initialize
@words_low = %w[minnie mickey daisy donald pluto goofy anna elsa alice]
@words_medium = %w[tigger cinderella bambi pocahontas eeyor rabbit mulan belle dumbo]
@words_high = %w[esmeralda quasimodo anastasia mowgli anastasia drizella kocoum maleficent]

Choose a reason for hiding this comment

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

These arrays are only used in one place, in selection_level. That means that making them instance variables might not be appropriate, you could make them local variables in selection_level instead.

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