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

Joe Ray #430

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

Joe Ray #430

wants to merge 13 commits into from

Conversation

joeray100
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.

Joe, I left a few comments for things to consider. The main thing I'd encourage you to do before mod 1 starts is re-do speckled_frogs using iteration.

end

def change_protein
@protein.insert("Chicken") #inserts Chicken for protein
Copy link

Choose a reason for hiding this comment

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

What data type is @protein? I think you're looking for a different way to reassign @protein here.

Copy link
Author

Choose a reason for hiding this comment

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

@protein is an object/instance variable.

Comment on lines +54 to +68
puts "#{x} speckled frogs sat on a log"
puts 'eating some most delicious bugs.'
puts 'One jumped in the pool where its nice and cool,'
puts "then there were #{y} speckled frogs."
puts ''
puts "#{y} speckled frogs sat on a log"
puts 'eating some most delicious bugs.'
puts 'One jumped in the pool where its nice and cool,'
puts "then there was #{z} speckled frog."
puts ''
puts "#{z} speckled frog sat on a log"
puts 'eating some most delicious bugs.'
puts 'One jumped in the pool where its nice and cool,'
puts 'then there were no more speckled frogs!'
puts '-----------------------------------------------'
Copy link

Choose a reason for hiding this comment

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

Try re-doing this exercise using iteration.

Copy link
Author

Choose a reason for hiding this comment

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

OK, thanks. I'm going to try and finish up where I'm at in the ruby exercises then give this another go.

Comment on lines +5 to +9
def encrypt(string, key)
string_to_ascii_array = string.chars.map {|char| char.ord}
shifted = string_to_ascii_array.map {|char| char + key}
shifted.map {|char| char.chr }.join(', ')
end
Copy link

Choose a reason for hiding this comment

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

WARNING: Never copy and paste code as your own. If work is still in progress and copied code is for reference, make a comment to that effect.

Copy link
Author

Choose a reason for hiding this comment

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

So I have a question about this if/when you have time. I know there are usually multiple ways to solve problems but programmers typically settle on one. In situations like these are you saying it's ok to use code already written by others so long as I leave a comment saying so? Sorry I feel like this is a tricky area as I'm sure programmers use code that's already written regularly. If not, I'm sure they use code written by others as inspiration for their own. Is what you stated above your best advice for how to handle situations like these going forward?

@@ -0,0 +1,18 @@
def FizzBuzz (x,y)
while x <= y
Copy link

Choose a reason for hiding this comment

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

When there are assumptions around numbers, like y > x, using variable names like max and min are extremely helpful.

Copy link
Author

Choose a reason for hiding this comment

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

I understand and appreciate the feedback.

Comment on lines +9 to +18
2. First, I defined a method called encrypt for my CaesarCipher class. Then I converted
the string to an array of characters using `.chars`. Secondly, you can use `.map`
to iterate through the array and find the ASCII characters using `.ord`. I now needed to
shift. To do this, I used `.map` to iterate through the ASCII character codes
and then added our "shift value", which I called "key". Next, using `.join`
I was able to convert and join our new characters in the shifted array into
a new string of characters correlated to ASCII code. I got close to the end by defining
and instantiating a new object called "cipher" using the `.new` method. Lastly,
I printed the encrypted message and designated that message with they argument
and key(or value to be shifted).
Copy link

Choose a reason for hiding this comment

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

Good work explaining the code in your CaesarCipher.

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