Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hharper/f756bd559252240141d4 to your computer and use it in GitHub Desktop.
Save hharper/f756bd559252240141d4 to your computer and use it in GitHub Desktop.
Homework, W01D02 - HH
puts ("Hi, I'm C-3P0, human-cyborg relations")
puts ("What's your name?")
#obtains the user's name
user_name = gets.chomp()
puts("It is a pleasure to meet you #{user_name}. Have you ever met a protocol droid before?")
#obtains user's answer
user_answer = gets.chomp()
puts("#{user_answer}? How interesting, for someone from around these parts.")
puts("I'm terribly sorry for prying, but you don't by any chance go by the alias of Obi Wan Kenobi, do you? (Please answer 'I do' or 'I don't) ")
#obtains user's answer
user_alias = gets.chomp()
if user_alias == ("I do" || "i do" || "I DO" || "i Do")
puts("Oh, marvelous! Say hello to R2-D2; he's been looking all over for you.")
# the comparison message is same as doing lots of 'elsifs:'
# elsif user_alias == "i do"
# puts("Oh, marvelous! Say hello to R2-D2; he's been looking all over for you.")
# elsif user_alias == "I DO"
# puts("Oh, marvelous! Say hello to R2-D2; he's been looking all over for you.")
# elsif user_alias == "i Do"
# puts("Oh, marvelous! Say hello to R2-D2; he's been looking all over for you.")
else
puts("I've really enjoyed speaking with you, #{user_name} but if you'll please excuse me, I have to help my friend find someone named Ob-Wan Kenobi.")
puts("What's your favorite farewell?")
#obtains user's favorite farewell
fav_farewell = gets.chomp()
puts ("#{fav_farewell} to you too.")
puts ("Well R2, I suppose we'll just have to keep looking.")
puts ("R2-D2: (Agreeable droid noises.)")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment