Last active
December 22, 2015 19:29
-
-
Save chug2k/6520211 to your computer and use it in GitHub Desktop.
for zaidi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hi - This is Charles, and I'm going to write just a tiny bit of code. | |
# I hope it'll clear things up for you. | |
# I think you're getting tripped up on stuff you've learned before - | |
# please try to approach this stuff with an open mind. It requires | |
# patience, but you'll eventually get the hang of it, I promise. | |
# These early steps are supposed to be hard! Patience now will | |
# pay off tenfold in a few weeks. | |
# I see you doing things that you must have seen in other languages! | |
# That's cool, but please be patient and really | |
# try to learn things here from the ground up. | |
# The best place to do that is to read the course material! | |
# This might be more confusing, but bear with me... | |
def a_locked?(a) | |
if a == 3 || a == 4 || a == 5 | |
false | |
else | |
true | |
end | |
end | |
def b_locked?(b) | |
if b == 2 | |
false | |
else | |
true | |
end | |
end | |
def c_locked(c) | |
# We could write it the same we have been, | |
# or we could write things more succinctly like so: | |
return false if (c == 5 || c == 6) | |
# you could also say it as... | |
# return (c != 5 && c != 6) | |
# that's saying...return true if c is not 5 AND c is not 6 | |
# the first one is the opposite of that. it's just logic tricks. | |
end | |
def d_locked(d) | |
# Can you fill this in....? | |
end | |
def lock(a, b, c, d) | |
return a_locked(a) && b_locked(b) # && more stuff needed here... | |
# The above line is incomplete. Please finish it! | |
end | |
def lock(a, b, c, d) | |
if (a == 3) || (a == 4) || (a == 5) | |
"unlocked" | |
else | |
"locked" | |
elsif | |
b = 2 | |
"locked" | |
elsif c = 5 || c ==6 | |
"unlocked" | |
elseif d = 8 || d == 9 || d == 0 | |
"unlocked" | |
else | |
"locked" | |
end | |
end | |
# I think we still have to talk about | |
# arguments and variables. I will mail you an exercise. | |
def can_i_get?(liketoget, money) | |
if (computer) && (money > 1100) | |
"true" | |
elsif (ipad) && (money > 500) | |
"true" | |
else | |
"false" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment