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

Wyatt Wicks #433

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

Conversation

Wyattwicks
Copy link

Here is my prework!

Copy link

@ap2322 ap2322 left a comment

Choose a reason for hiding this comment

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

Wyatt, good work!

Comment on lines +29 to +30
p "1 speckled frog sat on a log"
\
Copy link

Choose a reason for hiding this comment

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

This is a bit of an anti-patttern since puts automatically adds a new line at the end of a string.

Comment on lines +23 to +24
number_frogs = (1..10).to_a
number_frogs.sort! {|x, y| y <=> x}
Copy link

Choose a reason for hiding this comment

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

Nice work using range and array to set up your number_frogs

Comment on lines +36 to +47
p "eating some most delicious bugs."
\
p "One jumped in the pool where its nice and cool,"
\

if new_number == 0
p "then there were no more speckled frogs!"
elsif new_number == 1
p "then there was one speckled frog."
else
p "then there were #{new_number} speckled frogs."
end
Copy link

Choose a reason for hiding this comment

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

Good work using iteration and looking for where you can DRY (don't repeat yourself) your code.

Comment on lines +8 to +9
message.chars.map {|char| alphabet.include?(char.downcase) ?
alphabet[alphabet.find_index(char.downcase) + shift - alphabet.size] : char}.join
Copy link

Choose a reason for hiding this comment

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

There is a LOT going on here. As a rule of thumb, if you have more than one line in an enumerable block, use do and end instead of {} for readability.

Warning: Be very careful about copying and pasting solutions and changing variable names. Understanding how those methods all work together will allow you to design your solutions with intention.

Comment on lines +5 to +10
3. Now comes the actual code. We use message.chars to separate whatever message we type in to a new array of individual characters. then we use the .map command to map out this array of characters in a new way.
4. the code after the .map command is telling the computer that for each character in our array, we first check if the character is in the alphabet array that we created earlier. This eliminates spaces, symbols, and numbers so the end result only has the characters shifted and not the other spaces and punction marks. using the .downcase command will make it so that even if the letters in the message are capitalized, they will still be able to be found in our alphabet array as those letters are all lower case.
5. then we use alphabet.find_index(char.downcase) to find the numbered position of each character in the alphabet array.
6. we then add shift to the index number to each character. shift has been defined as the number you want the letters to move, so by adding that number to each character, the new character is the value of the old character's index plus the amount to shift.
7. I then subtracted the size of the alphabet (26) to account for any character that has been shifted higher than the amount of characters in the alphabet. This also wraps the characters around the alphabet again because there is no value in alphabet for anything higher than 26.
8. I then close out my maps bracket with :char so the program knows to do the above for every character in the message. I then use the .join command to take those new characters and rejoin them in to words again.
Copy link

Choose a reason for hiding this comment

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

Good work defining the methods for yourself before implementing a solution from your research (stack overflow). I think you've explained all of these except the ternary operator ? :

map
include?
downcase
? : 
find_index
size
join

A different challenge that is more common in programming, would be to write out the steps of what you want to do in plain language first and then find the pieces of code to fit those steps.

Comment on lines +15 to +28
def add_topping(topping)
@toppings.append(topping)
puts "You added #{topping} to your burrito!"
end

def remove_topping(topping)
@toppings.delete(topping)
puts "You removed #{topping} from your burrito!"
end

def change_protein(protein)
@protein = protein
puts "You changed your protein to #{protein}!"
end
Copy link

Choose a reason for hiding this comment

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

Good job updating the attributes of the class.

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